mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 03:06:29 +00:00
add wallet owns flag to inputv2
This commit is contained in:
parent
5b9ade5f15
commit
f55fd7f05a
2 changed files with 34 additions and 5 deletions
|
@ -54,6 +54,8 @@ class InputV2 {
|
|||
late final String? witness;
|
||||
late final String? innerRedeemScriptAsm;
|
||||
|
||||
late final bool walletOwns;
|
||||
|
||||
@ignore
|
||||
BigInt get value => BigInt.parse(valueStringSats);
|
||||
|
||||
|
@ -68,6 +70,7 @@ class InputV2 {
|
|||
required String? witness,
|
||||
required String? innerRedeemScriptAsm,
|
||||
required String? coinbase,
|
||||
required bool walletOwns,
|
||||
}) =>
|
||||
InputV2()
|
||||
..scriptSigHex = scriptSigHex
|
||||
|
@ -77,7 +80,32 @@ class InputV2 {
|
|||
..valueStringSats = valueStringSats
|
||||
..witness = witness
|
||||
..innerRedeemScriptAsm = innerRedeemScriptAsm
|
||||
..coinbase = coinbase;
|
||||
..innerRedeemScriptAsm = innerRedeemScriptAsm
|
||||
..walletOwns = walletOwns;
|
||||
|
||||
InputV2 copyWith({
|
||||
String? scriptSigHex,
|
||||
int? sequence,
|
||||
OutpointV2? outpoint,
|
||||
List<String>? addresses,
|
||||
String? valueStringSats,
|
||||
String? coinbase,
|
||||
String? witness,
|
||||
String? innerRedeemScriptAsm,
|
||||
bool? walletOwns,
|
||||
}) {
|
||||
return InputV2.isarCantDoRequiredInDefaultConstructor(
|
||||
scriptSigHex: scriptSigHex ?? this.scriptSigHex,
|
||||
sequence: sequence ?? this.sequence,
|
||||
outpoint: outpoint ?? this.outpoint,
|
||||
addresses: addresses ?? this.addresses,
|
||||
valueStringSats: valueStringSats ?? this.valueStringSats,
|
||||
coinbase: coinbase ?? this.coinbase,
|
||||
witness: witness ?? this.witness,
|
||||
innerRedeemScriptAsm: innerRedeemScriptAsm ?? this.innerRedeemScriptAsm,
|
||||
walletOwns: walletOwns ?? this.walletOwns,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
|
|
|
@ -2119,16 +2119,17 @@ class BitcoinCashWallet extends CoinServiceAPI
|
|||
witness: map["witness"] as String?,
|
||||
coinbase: coinbase,
|
||||
innerRedeemScriptAsm: map["innerRedeemscriptAsm"] as String?,
|
||||
// don't know yet if wallet owns. Need addresses first
|
||||
walletOwns: false,
|
||||
);
|
||||
|
||||
inputs.add(input);
|
||||
}
|
||||
|
||||
for (final input in inputs) {
|
||||
if (allAddressesSet.intersection(input.addresses.toSet()).isNotEmpty) {
|
||||
wasSentFromThisWallet = true;
|
||||
amountSentFromThisWallet += input.value;
|
||||
}
|
||||
|
||||
inputs.add(
|
||||
wasSentFromThisWallet ? input.copyWith(walletOwns: true) : input);
|
||||
}
|
||||
|
||||
// parse outputs
|
||||
|
|
Loading…
Reference in a new issue