Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initial implementation of walletv2 #6429

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joschisan
Copy link
Contributor

No description provided.

@joschisan joschisan requested review from a team as code owners November 21, 2024 06:53
@joschisan joschisan force-pushed the walletv2 branch 2 times, most recently from bf6127b to 68aae67 Compare November 21, 2024 08:44
@joschisan joschisan requested a review from a team as a code owner November 21, 2024 08:44
@joschisan joschisan force-pushed the walletv2 branch 25 times, most recently from 41ee984 to 2e36e7a Compare November 23, 2024 16:15
@joschisan joschisan force-pushed the walletv2 branch 3 times, most recently from 6582968 to 994083a Compare November 24, 2024 08:26
DustAmount,
#[error("Federation returned an error: {0}")]
FederationError(String),
#[error("The federation has no vetted gateways")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong message?

FederationError(String),
#[error("The federation has no vetted gateways")]
NoConsensusFeerateAvailable,
#[error("The client does not have sufficicent funds to send the payment")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[error("The client does not have sufficicent funds to send the payment")]
#[error("The client does not have sufficient funds to send the payment")]

pub enum SendError {
#[error("Address is from a different network then the federation.")]
WrongNetwork,
#[error("The amount is to small to be send on-chain")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[error("The amount is to small to be send on-chain")]
#[error("The amount is too small to be sent on-chain")]

///
/// # Errors
/// - This constructor returns an error if the relative fee is in excess of
/// one thousand parts per million.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ten thousand?

Comment on lines +120 to +121
// change in feerate it stays invalid. Otherwise there exists a race condition
// where a client might consider a actually accepted transaction as rejected.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// change in feerate it stays invalid. Otherwise there exists a race condition
// where a client might consider a actually accepted transaction as rejected.
// change in feerate, it remains invalid. Otherwise, there exists a race condition
// where a client might consider an actually accepted transaction as rejected.

#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
pub struct ReceiveFee {
// This index ensures that once a Fedimint transaction becomes invalid due to a
// change in feerate it stays invalid. Otherwise there exists a race condition
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

WrongOutputScript,
#[error("No up to date feerate is available at the moment. Please try again later.")]
NoConsensusFeerateAvailable,
#[error("The fee index is outdated. Please construct an new transaction.")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[error("The fee index is outdated. Please construct an new transaction.")]
#[error("The fee index is outdated. Please construct a new transaction.")]

NoConsensusFeerateAvailable,
#[error("The fee index is outdated. Please construct an new transaction.")]
IncorrectFeeRateIndex,
#[error("The total transaction fee is to low. Please construct an new transaction.")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[error("The total transaction fee is to low. Please construct an new transaction.")]
#[error("The total transaction fee is too low. Please construct a new transaction.")]

IncorrectFeeRateIndex,
#[error("The total transaction fee is to low. Please construct an new transaction.")]
InsufficientTotalFee,
#[error("Constructing the pegin transaction caused and arithmetic overflow")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[error("Constructing the pegin transaction caused and arithmetic overflow")]
#[error("Constructing the pegin transaction caused an arithmetic overflow")]

pub enum WalletOutputError {
#[error("The wallet output version is not supported by this federation")]
UnknownOutputVariant(#[from] UnknownWalletOutputVariantError),
#[error("Connected bitcoind is on wrong network.")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong message

NoFederationUTXO,
#[error("No up to date feerate is available at the moment. Please try again later.")]
NoConsensusFeerateAvailable,
#[error("The fee index is outdated. Please construct an new transaction.")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...

NoConsensusFeerateAvailable,
#[error("The fee index is outdated. Please construct an new transaction.")]
IncorrectFeeRateIndex,
#[error("The total transaction fee is to low. Please construct an new transaction.")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...

#[error("The fee index is outdated. Please construct an new transaction.")]
IncorrectFeeRateIndex,
#[error("The total transaction fee is to low. Please construct an new transaction.")]
InsufficicentTotalFee,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
InsufficicentTotalFee,
InsufficientTotalFee,

IncorrectFeeRateIndex,
#[error("The total transaction fee is to low. Please construct an new transaction.")]
InsufficicentTotalFee,
#[error("Constructing the pegout transaction caused and arithmetic overflow")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...

let outpoint = bitcoin::OutPoint {
txid: transaction.compute_txid(),
vout: u32::try_from(vout).expect(
"Bitcoin transaction has more then u32::MAX outputs",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Bitcoin transaction has more then u32::MAX outputs",
"Bitcoin transaction has more than u32::MAX outputs",

Comment on lines +388 to +390
if Some(feerate) == dbtx.insert_entry(&FeeRateVoteKey(peer), &feerate).await {
bail!("Fee rate vote is redundant");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if Some(feerate) == dbtx.insert_entry(&FeeRateVoteKey(peer), &feerate).await {
bail!("Fee rate vote is redundant");
}
ensure!(
Some(feerate) != dbtx.insert_entry(&FeeRateVoteKey(peer), &feerate).await,
"Fee rate vote is redundant"
);

// Since the total number of transactions is bound the following addition
// and cast cannot overflow or truncate.

(unsigned_count + pending_count) as u32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(unsigned_count + pending_count) as u32
(unsigned_count + pending_count).try_into().expect("Since the total number of transactions is bound the addition cannot overflow or truncate")

@douglaz
Copy link
Contributor

douglaz commented Nov 25, 2024

Concept NACK if the goal is to replace the "wallet v1" module.

The primary issue here is that creating a single UTXO for the federation effectively and unavoidably turns the federation into a "mixer" by default.

While a mixer might be an interesting project from a cypherpunk perspective, it poses significant risks for guardians and gateway operators, which could hinder its adoption by most real-world communities. Additionally, it may attract unwanted attention to the project and its developers.

My main objection isn't to the existence of this module, but to it being the standard or default for fedimints. The standard module should have reasonable UTXO management suitable for all use cases. At a minimum, it should avoid unnecessary mixing of UTXOs.

@@ -6,7 +6,7 @@ if grep -E "(fedimint-mint|fedimint-wallet|fedimint-ln)" fedimint-server/Cargo.t
>&2 echo "fedimint-server/Cargo.toml must not depend on modules"
return 1
fi
if grep -E "(fedimint-mint|fedimint-wallet|fedimint-ln-(server|client))" fedimint-testing/Cargo.toml >&2 ; then
if grep -E "(fedimint-mint|fedimint-wallet-|fedimint-ln-(server|client))" fedimint-testing/Cargo.toml >&2 ; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v2 module is also a module ... IIRC this rule is to prevent circular deps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants