fix: output address on confirmation based on selected network

This commit is contained in:
Vlad Stan 2022-09-21 17:13:05 +03:00
parent dc11205128
commit 6e405d1fc4
4 changed files with 9 additions and 3 deletions

View File

@ -80,6 +80,7 @@ class CreatePsbt(BaseModel):
class ExtractPsbt(BaseModel):
psbtBase64 = "" # // todo snake case
inputs: List[TransactionInput]
network = "Mainnet"
class SignedTransaction(BaseModel):

View File

@ -11,7 +11,8 @@ async function payment(path) {
'mempool-endpoint',
'sats-denominated',
'serial-signer-ref',
'adminkey'
'adminkey',
'network'
],
watch: {
immediate: true,
@ -279,7 +280,8 @@ async function payment(path) {
this.adminkey,
{
psbtBase64,
inputs: this.tx.inputs
inputs: this.tx.inputs,
network: this.network
}
)
return data

View File

@ -136,6 +136,7 @@
:adminkey="g.user.wallets[0].adminkey"
:serial-signer-ref="$refs.serialSigner"
:sats-denominated="config.sats_denominated"
:network="config.network"
@broadcast-done="handleBroadcastSuccess"
></payment>
<!-- todo: no more utxos.data -->

View File

@ -4,6 +4,7 @@ from http import HTTPStatus
import httpx
from embit import finalizer, script
from embit.ec import PublicKey
from embit.networks import NETWORKS
from embit.psbt import PSBT, DerivationPath
from embit.transaction import Transaction, TransactionInput, TransactionOutput
from fastapi import Query, Request
@ -295,6 +296,7 @@ async def api_psbt_create(
async def api_psbt_extract_tx(
data: ExtractPsbt, w: WalletTypeInfo = Depends(require_admin_key)
):
network = NETWORKS["main"] if data.network == "Mainnet" else NETWORKS["test"]
res = SignedTransaction()
try:
psbt = PSBT.from_base64(data.psbtBase64)
@ -316,7 +318,7 @@ async def api_psbt_extract_tx(
for out in transaction.vout:
tx["outputs"].append(
{"amount": out.value, "address": out.script_pubkey.address()}
{"amount": out.value, "address": out.script_pubkey.address(network)}
)
res.tx_json = json.dumps(tx)
except Exception as e: