mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-11 05:04:35 +00:00
handle particl txs with ct_fee, rangeproof, and/or data_hex keys
This commit is contained in:
parent
2cbca50d52
commit
ec4889fd64
1 changed files with 50 additions and 2 deletions
|
@ -164,7 +164,7 @@ class ParticlWallet extends Bip39HDWallet
|
|||
(inputTx["vout"] as List).firstWhere((e) => e["n"] == vout)
|
||||
as Map);
|
||||
|
||||
final prevOut = OutputV2.fromElectrumXJson(
|
||||
final prevOut = fromElectrumXJsonParticl(
|
||||
prevOutJson,
|
||||
decimalPlaces: cryptoCurrency.fractionDigits,
|
||||
isFullAmountNotSats: true,
|
||||
|
@ -204,7 +204,7 @@ class ParticlWallet extends Bip39HDWallet
|
|||
// Parse outputs.
|
||||
final List<OutputV2> outputs = [];
|
||||
for (final outputJson in txData["vout"] as List) {
|
||||
OutputV2 output = OutputV2.fromElectrumXJson(
|
||||
OutputV2 output = fromElectrumXJsonParticl(
|
||||
Map<String, dynamic>.from(outputJson as Map),
|
||||
decimalPlaces: cryptoCurrency.fractionDigits,
|
||||
isFullAmountNotSats: true,
|
||||
|
@ -439,4 +439,52 @@ class ParticlWallet extends Bip39HDWallet
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// OutputV2.fromElectrumXJson wrapper for Particl-specific outputs.
|
||||
static OutputV2 fromElectrumXJsonParticl(
|
||||
Map<String, dynamic> json, {
|
||||
// Other params just passed thru to fromElectrumXJson for transparent outs.
|
||||
required bool walletOwns,
|
||||
required bool isFullAmountNotSats,
|
||||
required int decimalPlaces,
|
||||
}) {
|
||||
// TODO: [prio=med] Confirm that all the tx types below are handled well.
|
||||
// Right now we essentially ignore txs with ct_fee, rangeproof, or data_hex
|
||||
// keys. We may also want to set walletOwns to true (if we know the owner).
|
||||
if (json.containsKey('ct_fee')) {
|
||||
// Blind output, ignore for now.
|
||||
return OutputV2.isarCantDoRequiredInDefaultConstructor(
|
||||
scriptPubKeyHex: '',
|
||||
valueStringSats: '0',
|
||||
addresses: [],
|
||||
walletOwns: false,
|
||||
);
|
||||
} else if (json.containsKey('rangeproof')) {
|
||||
// Private RingCT output, ignore for now.
|
||||
return OutputV2.isarCantDoRequiredInDefaultConstructor(
|
||||
scriptPubKeyHex: '',
|
||||
valueStringSats: '0',
|
||||
addresses: [],
|
||||
walletOwns: false,
|
||||
);
|
||||
} else if (json.containsKey('data_hex')) {
|
||||
// Data output, ignore for now.
|
||||
return OutputV2.isarCantDoRequiredInDefaultConstructor(
|
||||
scriptPubKeyHex: '',
|
||||
valueStringSats: '0',
|
||||
addresses: [],
|
||||
walletOwns: false,
|
||||
);
|
||||
} else if (json.containsKey('scriptPubKey')) {
|
||||
// Transparent output.
|
||||
return OutputV2.fromElectrumXJson(
|
||||
json,
|
||||
walletOwns: walletOwns,
|
||||
isFullAmountNotSats: isFullAmountNotSats,
|
||||
decimalPlaces: decimalPlaces,
|
||||
);
|
||||
} else {
|
||||
throw Exception("Unknown output type: $json");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue