add asm to required params list and some other paynym tx fixes

This commit is contained in:
julian 2024-01-14 11:26:04 -06:00
parent 98338bdea2
commit a3120932dd
19 changed files with 56 additions and 45 deletions

View file

@ -64,7 +64,7 @@ class InputV2 {
static InputV2 isarCantDoRequiredInDefaultConstructor({
required String? scriptSigHex,
String? scriptSigAsm,
required String? scriptSigAsm,
required int? sequence,
required OutpointV2? outpoint,
required List<String> addresses,

View file

@ -10,6 +10,7 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
@ -1021,6 +1022,14 @@ class _DesktopTransactionCardRowState
),
),
),
if (kDebugMode)
Expanded(
flex: 3,
child: Text(
_transaction.subType.name,
style: STextStyles.label(context),
),
),
Expanded(
flex: 4,
child: Text(

View file

@ -19,8 +19,6 @@ import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub
import 'package:stackwallet/providers/global/locale_provider.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/providers/global/price_provider.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart';
import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart';
import 'package:stackwallet/themes/coin_icon_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
@ -59,15 +57,11 @@ class _DesktopPaynymSendDialogState
extends ConsumerState<DesktopPaynymSendDialog> {
@override
Widget build(BuildContext context) {
final wallet =
ref.watch(pWallets.select((value) => value.getWallet(widget.walletId)));
final String locale = ref.watch(
localeServiceChangeNotifierProvider.select((value) => value.locale));
final coin = ref.watch(pWalletCoin(widget.walletId));
final isFiro = coin == Coin.firo || coin == Coin.firoTestNet;
return DesktopDialog(
maxHeight: double.infinity,
maxWidth: 580,
@ -79,7 +73,7 @@ class _DesktopPaynymSendDialogState
Padding(
padding: const EdgeInsets.only(left: 32),
child: Text(
"Send ${coin.ticker.toUpperCase()}",
"Send ${coin.ticker}",
style: STextStyles.desktopH3(context),
),
),
@ -117,9 +111,7 @@ class _DesktopPaynymSendDialogState
height: 2,
),
Text(
isFiro
? "${ref.watch(publicPrivateBalanceStateProvider.state).state} balance"
: "Available balance",
"Available balance",
style: STextStyles.baseXS(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
@ -135,36 +127,9 @@ class _DesktopPaynymSendDialogState
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
!isFiro
? ref.watch(pAmountFormatter(coin)).format(ref
.watch(pWalletBalance(widget.walletId))
.spendable)
: ref
.watch(
publicPrivateBalanceStateProvider
.state,
)
.state ==
"Private"
? ref.watch(pAmountFormatter(coin)).format(
ref
.watch(
pWalletBalance(widget.walletId))
.spendable,
)
: ref.watch(pAmountFormatter(coin)).format(
ref
.watch(pWalletBalanceSecondary(
widget.walletId))
.spendable,
),
// ? ref.watch(pAmountFormatter(coin)).format(
// (manager.wallet as FiroWallet)
// .availablePrivateBalance())
// : ref.watch(pAmountFormatter(coin)).format(
// (manager.wallet as FiroWallet)
// .availablePublicBalance(),
// ),
ref.watch(pAmountFormatter(coin)).format(ref
.watch(pWalletBalance(widget.walletId))
.spendable),
style: STextStyles.titleBold12(context),
textAlign: TextAlign.right,
),
@ -172,7 +137,7 @@ class _DesktopPaynymSendDialogState
height: 2,
),
Text(
"${((!isFiro ? ref.watch(pWalletBalance(widget.walletId)).spendable.decimal : ref.watch(publicPrivateBalanceStateProvider.state).state == "Private" ? ref.watch(pWalletBalance(widget.walletId)).spendable.decimal : ref.watch(pWalletBalanceSecondary(widget.walletId)).spendable.decimal) * ref.watch(
"${(ref.watch(pWalletBalance(widget.walletId)).spendable.decimal * ref.watch(
priceAnd24hChangeNotifierProvider.select(
(value) => value.getPrice(coin).item1,
),

View file

@ -863,6 +863,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
if (isPaynymSend) {
sendToController.text = widget.accountLite!.nymName;
WidgetsBinding.instance.addPostFrameCallback(
(_) => _setValidAddressProviders(sendToController.text));
}
_cryptoFocus.addListener(() {

View file

@ -76,6 +76,7 @@ mixin ElectrumXParsing {
final input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: map["scriptSig"]?["hex"] as String?,
scriptSigAsm: map["scriptSig"]?["asm"] as String?,
sequence: map["sequence"] as int?,
outpoint: outpoint,
valueStringSats: valueStringSats,

View file

@ -1,3 +1,4 @@
import 'package:bip47/src/util.dart';
import 'package:isar/isar.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
@ -210,6 +211,21 @@ class BitcoinWallet<T extends PaynymCurrencyInterface> extends Bip39HDWallet<T>
TransactionType type;
TransactionSubType subType = TransactionSubType.none;
if (outputs.length > 1 && inputs.isNotEmpty) {
for (int i = 0; i < outputs.length; i++) {
List<String>? scriptChunks = outputs[i].scriptPubKeyAsm?.split(" ");
if (scriptChunks?.length == 2 && scriptChunks?[0] == "OP_RETURN") {
final blindedPaymentCode = scriptChunks![1];
final bytes = blindedPaymentCode.fromHex;
// https://en.bitcoin.it/wiki/BIP_0047#Sending
if (bytes.length == 80 && bytes.first == 1) {
subType = TransactionSubType.bip47Notification;
break;
}
}
}
}
// At least one input was owned by this wallet.
if (wasSentFromThisWallet) {

View file

@ -189,6 +189,7 @@ class BitcoincashWallet extends Bip39HDWallet
InputV2 input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: map["scriptSig"]?["hex"] as String?,
scriptSigAsm: map["scriptSig"]?["asm"] as String?,
sequence: map["sequence"] as int?,
outpoint: outpoint,
valueStringSats: valueStringSats,

View file

@ -152,6 +152,7 @@ class DogecoinWallet extends Bip39HDWallet
InputV2 input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: map["scriptSig"]?["hex"] as String?,
scriptSigAsm: map["scriptSig"]?["asm"] as String?,
sequence: map["sequence"] as int?,
outpoint: outpoint,
valueStringSats: valueStringSats,

View file

@ -183,6 +183,7 @@ class EcashWallet extends Bip39HDWallet
InputV2 input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: map["scriptSig"]?["hex"] as String?,
scriptSigAsm: map["scriptSig"]?["asm"] as String?,
sequence: map["sequence"] as int?,
outpoint: outpoint,
valueStringSats: valueStringSats,

View file

@ -973,6 +973,7 @@ class EpiccashWallet extends Bip39Wallet {
);
InputV2 input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: null,
scriptSigAsm: null,
sequence: null,
outpoint: null,
addresses: [if (addressTo != null) addressTo],

View file

@ -286,6 +286,7 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface {
);
InputV2 input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: null,
scriptSigAsm: null,
sequence: null,
outpoint: null,
addresses: [addressFrom],

View file

@ -399,6 +399,7 @@ class FiroWallet extends Bip39HDWallet
InputV2 input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: map["scriptSig"]?["hex"] as String?,
scriptSigAsm: map["scriptSig"]?["asm"] as String?,
sequence: map["sequence"] as int?,
outpoint: outpoint,
valueStringSats: valueStringSats,

View file

@ -159,6 +159,7 @@ class LitecoinWallet extends Bip39HDWallet
InputV2 input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: map["scriptSig"]?["hex"] as String?,
scriptSigAsm: map["scriptSig"]?["asm"] as String?,
sequence: map["sequence"] as int?,
outpoint: outpoint,
valueStringSats: valueStringSats,

View file

@ -183,6 +183,7 @@ class NamecoinWallet extends Bip39HDWallet
InputV2 input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: map["scriptSig"]?["hex"] as String?,
scriptSigAsm: map["scriptSig"]?["asm"] as String?,
sequence: map["sequence"] as int?,
outpoint: outpoint,
valueStringSats: valueStringSats,

View file

@ -204,6 +204,7 @@ class ParticlWallet extends Bip39HDWallet
InputV2 input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: map["scriptSig"]?["hex"] as String?,
scriptSigAsm: map["scriptSig"]?["asm"] as String?,
sequence: map["sequence"] as int?,
outpoint: outpoint,
valueStringSats: valueStringSats,
@ -355,6 +356,7 @@ class ParticlWallet extends Bip39HDWallet
tempInputs.add(
InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: txb.inputs.first.script?.toHex,
scriptSigAsm: null,
sequence: 0xffffffff - 1,
outpoint: OutpointV2.isarCantDoRequiredInDefaultConstructor(
txid: utxoSigningData[i].utxo.txid,

View file

@ -416,6 +416,7 @@ class StellarWallet extends Bip39Wallet<Stellar> {
);
InputV2 input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: null,
scriptSigAsm: null,
sequence: null,
outpoint: null,
addresses: [addressFrom],
@ -496,6 +497,7 @@ class StellarWallet extends Bip39Wallet<Stellar> {
);
InputV2 input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: null,
scriptSigAsm: null,
sequence: null,
outpoint: null,
addresses: [

View file

@ -465,6 +465,7 @@ class EthTokenWallet extends Wallet {
);
InputV2 input = InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: null,
scriptSigAsm: null,
sequence: null,
outpoint: null,
addresses: [addressFrom],

View file

@ -687,6 +687,7 @@ mixin ElectrumXInterface<T extends Bip39HDCurrency> on Bip39HDWallet<T> {
tempInputs.add(
InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: txb.inputs.first.script?.toHex,
scriptSigAsm: null,
sequence: 0xffffffff - 1,
outpoint: OutpointV2.isarCantDoRequiredInDefaultConstructor(
txid: utxoSigningData[i].utxo.txid,
@ -764,9 +765,11 @@ mixin ElectrumXInterface<T extends Bip39HDCurrency> on Bip39HDWallet<T> {
inputs: List.unmodifiable(tempInputs),
outputs: List.unmodifiable(tempOutputs),
version: version,
type: tempOutputs.map((e) => e.walletOwns).fold(true, (p, e) => p &= e)
? TransactionType.sentToSelf
: TransactionType.outgoing,
type:
tempOutputs.map((e) => e.walletOwns).fold(true, (p, e) => p &= e) &&
txData.paynymAccountLite == null
? TransactionType.sentToSelf
: TransactionType.outgoing,
subType: TransactionSubType.none,
otherData: null,
),

View file

@ -484,6 +484,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
tempInputs.add(
InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: "d3",
scriptSigAsm: null,
sequence: 0xffffffff,
outpoint: null,
addresses: [],
@ -1103,6 +1104,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
tempInputs.add(
InputV2.isarCantDoRequiredInDefaultConstructor(
scriptSigHex: txb.inputs.first.script?.toHex,
scriptSigAsm: null,
sequence: 0xffffffff - 1,
outpoint: OutpointV2.isarCantDoRequiredInDefaultConstructor(
txid: input.utxo.txid,