mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 19:26:37 +00:00
handle 0 amounts
This commit is contained in:
parent
02ab644baf
commit
a62d94a60d
1 changed files with 6 additions and 27 deletions
|
@ -362,12 +362,16 @@ class Input {
|
||||||
class Output {
|
class Output {
|
||||||
// @HiveField(0)
|
// @HiveField(0)
|
||||||
final String? scriptpubkey;
|
final String? scriptpubkey;
|
||||||
|
|
||||||
// @HiveField(1)
|
// @HiveField(1)
|
||||||
final String? scriptpubkeyAsm;
|
final String? scriptpubkeyAsm;
|
||||||
|
|
||||||
// @HiveField(2)
|
// @HiveField(2)
|
||||||
final String? scriptpubkeyType;
|
final String? scriptpubkeyType;
|
||||||
|
|
||||||
// @HiveField(3)
|
// @HiveField(3)
|
||||||
final String scriptpubkeyAddress;
|
final String scriptpubkeyAddress;
|
||||||
|
|
||||||
// @HiveField(4)
|
// @HiveField(4)
|
||||||
final int value;
|
final int value;
|
||||||
|
|
||||||
|
@ -381,9 +385,6 @@ class Output {
|
||||||
factory Output.fromJson(Map<String, dynamic> json) {
|
factory Output.fromJson(Map<String, dynamic> json) {
|
||||||
// TODO determine if any of this code is needed.
|
// TODO determine if any of this code is needed.
|
||||||
try {
|
try {
|
||||||
// Particl has different tx types that need to be detected and handled here
|
|
||||||
// if (json.containsKey('scriptPubKey') as bool) {
|
|
||||||
// output is transparent
|
|
||||||
final address = json["scriptPubKey"]["addresses"] == null
|
final address = json["scriptPubKey"]["addresses"] == null
|
||||||
? json['scriptPubKey']['type'] as String
|
? json['scriptPubKey']['type'] as String
|
||||||
: json["scriptPubKey"]["addresses"][0] as String;
|
: json["scriptPubKey"]["addresses"][0] as String;
|
||||||
|
@ -392,35 +393,13 @@ class Output {
|
||||||
scriptpubkeyAsm: json['scriptPubKey']['asm'] as String?,
|
scriptpubkeyAsm: json['scriptPubKey']['asm'] as String?,
|
||||||
scriptpubkeyType: json['scriptPubKey']['type'] as String?,
|
scriptpubkeyType: json['scriptPubKey']['type'] as String?,
|
||||||
scriptpubkeyAddress: address,
|
scriptpubkeyAddress: address,
|
||||||
value: (Decimal.parse(json["value"].toString()) *
|
value: (Decimal.parse(
|
||||||
|
(json["value"] != null ? json["value"] : 0).toString()) *
|
||||||
Decimal.fromInt(Constants.satsPerCoin(Coin
|
Decimal.fromInt(Constants.satsPerCoin(Coin
|
||||||
.firo))) // dirty hack but we need 8 decimal places here to keep consistent data structure
|
.firo))) // dirty hack but we need 8 decimal places here to keep consistent data structure
|
||||||
.toBigInt()
|
.toBigInt()
|
||||||
.toInt(),
|
.toInt(),
|
||||||
);
|
);
|
||||||
// } /* else if (json.containsKey('ct_fee') as bool) {
|
|
||||||
// // or type: data
|
|
||||||
// // output is blinded (CT)
|
|
||||||
// } else if (json.containsKey('rangeproof') as bool) {
|
|
||||||
// // or valueCommitment or type: anon
|
|
||||||
// // output is private (RingCT)
|
|
||||||
// } */
|
|
||||||
// else {
|
|
||||||
// // TODO detect staking
|
|
||||||
// // TODO handle CT, RingCT, and staking accordingly
|
|
||||||
// // print("transaction not supported: ${json}");
|
|
||||||
// return Output(
|
|
||||||
// // Return output object with null values; allows wallet history to be built
|
|
||||||
// scriptpubkey: "",
|
|
||||||
// scriptpubkeyAsm: "",
|
|
||||||
// scriptpubkeyType: "",
|
|
||||||
// scriptpubkeyAddress: "",
|
|
||||||
// value: (Decimal.parse(0.toString()) *
|
|
||||||
// Decimal.fromInt(Constants.satsPerCoin(Coin
|
|
||||||
// .firo))) // dirty hack but we need 8 decimal places here to keep consistent data structure
|
|
||||||
// .toBigInt()
|
|
||||||
// .toInt());
|
|
||||||
// }
|
|
||||||
} catch (s, e) {
|
} catch (s, e) {
|
||||||
return Output(
|
return Output(
|
||||||
// Return output object with null values; allows wallet history to be built
|
// Return output object with null values; allows wallet history to be built
|
||||||
|
|
Loading…
Reference in a new issue