mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
feat: commit raw tx (from coldcard Q)
This commit is contained in:
parent
ddeef70d05
commit
d34b5b9112
1 changed files with 34 additions and 14 deletions
|
@ -441,21 +441,41 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
|||
}
|
||||
|
||||
Future<void> commitPsbtUR(List<String> urCodes) async {
|
||||
final ur = URDecoder();
|
||||
for (final inp in urCodes) {
|
||||
ur.receivePart(inp);
|
||||
}
|
||||
final result = (ur.result as UR);
|
||||
final cbor = result.cbor;
|
||||
final cborDecoder = CBORDecoder(cbor);
|
||||
final out = cborDecoder.decodeBytes();
|
||||
final bytes = out.$1;
|
||||
final base64psbt = base64Encode(bytes);
|
||||
final psbt = PsbtV2()..deserializeV0(base64Decode(base64psbt));
|
||||
if (urCodes.isEmpty) throw Exception("No QR code got scanned");
|
||||
bool isUr = urCodes.any((str) {
|
||||
return str.startsWith("ur:psbt/");
|
||||
});
|
||||
if (isUr) {
|
||||
final ur = URDecoder();
|
||||
for (final inp in urCodes) {
|
||||
ur.receivePart(inp);
|
||||
}
|
||||
final result = (ur.result as UR);
|
||||
final cbor = result.cbor;
|
||||
final cborDecoder = CBORDecoder(cbor);
|
||||
final out = cborDecoder.decodeBytes();
|
||||
final bytes = out.$1;
|
||||
final base64psbt = base64Encode(bytes);
|
||||
final psbt = PsbtV2()..deserializeV0(base64Decode(base64psbt));
|
||||
|
||||
// psbt.finalize();
|
||||
final finalized = base64Encode(psbt.serialize());
|
||||
await commitPsbt(finalized);
|
||||
// psbt.finalize();
|
||||
final finalized = base64Encode(psbt.serialize());
|
||||
await commitPsbt(finalized);
|
||||
} else {
|
||||
final btcTx = BtcTransaction.fromRaw(urCodes.first);
|
||||
|
||||
return PendingBitcoinTransaction(
|
||||
btcTx,
|
||||
type,
|
||||
electrumClient: electrumClient,
|
||||
amount: 0,
|
||||
fee: 0,
|
||||
feeRate: "",
|
||||
network: network,
|
||||
hasChange: true,
|
||||
isViewOnly: false,
|
||||
).commit();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue