Move bitcoin signer to rust#361
Open
0xh3rman wants to merge 5 commits into
Open
Conversation
479d3b4 to
403aebb
Compare
gemcoder21
approved these changes
Jun 2, 2026
| } | ||
| } | ||
|
|
||
| fn metadata_utxos(chain: BitcoinChain, metadata: &TransactionLoadMetadata) -> Result<Vec<UTXO>, SignerError> { |
Contributor
There was a problem hiding this comment.
use metadata.get_utxos()
| pub use primitives::testkit::signer_mock::TEST_PRIVATE_KEY; | ||
|
|
||
| pub const TEST_UTXO_TXID: &str = "0000000000000000000000000000000000000000000000000000000000000001"; | ||
| pub const TEST_ZCASH_BRANCH_ID: &str = "4dec4df0"; |
Contributor
There was a problem hiding this comment.
there is two TEST_ZCASH_BRANCH_ID vars
| struct EstimateFeeService { | ||
| init() {} | ||
|
|
||
| func provider(chain: Primitives.Chain) throws -> any GemGatewayEstimateFee { |
Contributor
There was a problem hiding this comment.
can we remove EstimateFeeService?
| }) | ||
| } | ||
|
|
||
| pub(crate) fn assert_invalid_input<T>(result: Result<T, SignerError>, expected: &str) { |
| Ok(hex::encode(tx.encode())) | ||
| } | ||
|
|
||
| pub(crate) fn branch_id_from_metadata(metadata: &TransactionLoadMetadata) -> Result<u32, SignerError> { |
Contributor
There was a problem hiding this comment.
move to TransactionLoadMetadata extension
| pub(super) fn estimate_fee(chain: BitcoinChain, inputs: &[PlanInput], outputs: &[PlanOutput], fee_rate: u64) -> Result<u64, SignerError> { | ||
| match chain { | ||
| BitcoinChain::Zcash => return estimate_zcash_fee(inputs, outputs), | ||
| BitcoinChain::Bitcoin | BitcoinChain::BitcoinCash | BitcoinChain::Litecoin | BitcoinChain::Doge => {} |
Contributor
There was a problem hiding this comment.
move this code to estimate_bitcoin_fee
| } | ||
|
|
||
| fn estimate_zcash_fee(inputs: &[PlanInput], outputs: &[PlanOutput]) -> Result<u64, SignerError> { | ||
| const MARGINAL_FEE: u64 = 5_000; |
Contributor
There was a problem hiding this comment.
move out of. the function
| const P2PKH_STANDARD_INPUT_SIZE: u64 = 150; | ||
| const P2PKH_STANDARD_OUTPUT_SIZE: u64 = 34; | ||
|
|
||
| let tx_in_total_size = inputs |
| address_for_hash(chain, public_key_hash(&public_key.to_bytes())) | ||
| } | ||
|
|
||
| pub fn destination_address(chain: BitcoinChain) -> String { |
Contributor
There was a problem hiding this comment.
add prefix mock_ in many places
| bitcoincash-addr = { version = "0.5.2" } | ||
| blake2b_simd = { version = "1.0.4" } | ||
| bs58 = { version = "0.5.1", features = ["check"] } | ||
| hex = { version = "0.4.3" } |
Contributor
There was a problem hiding this comment.
review if any typeshare models could be removed as well
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Transfer Matrix
sign_bitcoin_like+UtxoPlanner::Exact9f71a30b…)UtxoPlanner::Max5072b15a…)op_return_output+spend_outputssign_bitcoin_likelegacy pathb99c4551…)bitcoin_cash::sign_plan(BIP143 + 0x41)7360dbab…)zcash::sign_transparentZIP-244 v509cc92df…)UtxoPlanner::Max+ ZIP-317 feee5d68d6b…)Swap Matrix
SpendRequest::swapTransferuse_max_amount7360dbab…, intent)SpendRequest::swapContract (request.rs:42-58)9931d6dd…)759ef7a6…)