feat: Bitcoin transaction construction, signing, and sending

RealBitcoinTransactionService builds and signs native SegWit transactions
client-side (mempool.space only exposes UTXOs/fee-rate/broadcast, not
construction, unlike TronGrid): greedy largest-first UTXO selection over
confirmed UTXOs, inputs*68 + outputs*31 + 11 vsize heuristic for fees
(matching pezkuwi-exchange's proven approach), RBF-signaled inputs, and a
546-sat dust threshold that folds sub-dust change into the fee rather than
creating an uneconomical output.

Each input gets its own BIP143 sighash, signed via the existing raw-hash
signing primitive (NovaSigner.signRaw with skipMessageHashing) already used
for Ethereum/Tron, then DER-encoded with low-S normalization - no new
signing call path was added, only the DER encoding step.

Also fixes multiChainEncryptionFor/getMetaAccountKeypair to recognize
Bitcoin accounts: previously neither function had any Bitcoin (or Tron)
branch, so signing would have silently used the wrong keypair. Threads a
bitcoin flag through mapMetaAccountSecretsToKeypair/DerivationPath and
AccountSecrets.keypair(chain)/derivationPath(chain) the same way ethereum
already is.
This commit is contained in:
2026-07-12 15:51:37 -07:00
parent 1830024ed0
commit 6239526d43
12 changed files with 451 additions and 15 deletions
@@ -8,4 +8,6 @@ sealed interface TransactionExecution {
class Ethereum(val ethereumTransactionExecution: EthereumTransactionExecution) : TransactionExecution
class Substrate(val extrinsicExecutionResult: ExtrinsicExecutionResult) : TransactionExecution
class Bitcoin(val hash: String) : TransactionExecution
}