2022-07-04 17:40:47 +03:00
|
|
|
const mapAddressesData = a => ({
|
|
|
|
id: a.id,
|
|
|
|
address: a.address,
|
|
|
|
amount: a.amount,
|
|
|
|
wallet: a.wallet,
|
|
|
|
note: a.note,
|
|
|
|
|
2022-07-05 13:24:34 +03:00
|
|
|
isChange: a.branch_index === 1,
|
2022-07-04 17:40:47 +03:00
|
|
|
addressIndex: a.address_index,
|
|
|
|
hasActivity: a.has_activity
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapInputToSentHistory = (tx, addressData, vin) => ({
|
|
|
|
sent: true,
|
|
|
|
txId: tx.txid,
|
|
|
|
address: addressData.address,
|
2022-07-05 13:24:34 +03:00
|
|
|
isChange: addressData.isChange,
|
2022-07-04 17:40:47 +03:00
|
|
|
amount: vin.prevout.value,
|
|
|
|
date: blockTimeToDate(tx.status.block_time),
|
|
|
|
height: tx.status.block_height,
|
|
|
|
confirmed: tx.status.confirmed,
|
|
|
|
fee: tx.fee,
|
|
|
|
expanded: false
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapOutputToReceiveHistory = (tx, addressData, vout) => ({
|
|
|
|
received: true,
|
|
|
|
txId: tx.txid,
|
|
|
|
address: addressData.address,
|
2022-07-05 13:24:34 +03:00
|
|
|
isChange: addressData.isChange,
|
2022-07-04 17:40:47 +03:00
|
|
|
amount: vout.value,
|
|
|
|
date: blockTimeToDate(tx.status.block_time),
|
|
|
|
height: tx.status.block_height,
|
|
|
|
confirmed: tx.status.confirmed,
|
|
|
|
fee: tx.fee,
|
|
|
|
expanded: false
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapUtxoToPsbtInput = utxo => ({
|
|
|
|
tx_id: utxo.txId,
|
|
|
|
vout: utxo.vout,
|
|
|
|
amount: utxo.amount,
|
|
|
|
address: utxo.address,
|
2022-07-05 13:24:34 +03:00
|
|
|
branch_index: utxo.isChange ? 1 : 0,
|
2022-07-04 17:40:47 +03:00
|
|
|
address_index: utxo.addressIndex,
|
|
|
|
masterpub_fingerprint: utxo.masterpubFingerprint,
|
|
|
|
accountType: utxo.accountType,
|
|
|
|
txHex: ''
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapAddressDataToUtxo = (wallet, addressData, utxo) => ({
|
|
|
|
id: addressData.id,
|
|
|
|
address: addressData.address,
|
2022-07-05 13:24:34 +03:00
|
|
|
isChange: addressData.isChange,
|
2022-07-04 17:40:47 +03:00
|
|
|
addressIndex: addressData.addressIndex,
|
|
|
|
wallet: addressData.wallet,
|
|
|
|
accountType: addressData.accountType,
|
|
|
|
masterpubFingerprint: wallet.fingerprint,
|
|
|
|
txId: utxo.txid,
|
|
|
|
vout: utxo.vout,
|
|
|
|
confirmed: utxo.status.confirmed,
|
|
|
|
amount: utxo.value,
|
|
|
|
date: blockTimeToDate(utxo.status?.block_time),
|
|
|
|
sort: utxo.status?.block_time,
|
|
|
|
expanded: false,
|
|
|
|
selected: false
|
|
|
|
})
|
|
|
|
|
2022-08-01 13:21:14 +03:00
|
|
|
const mapWalletAccount = function (o) {
|
|
|
|
return Object.assign({}, o, {
|
|
|
|
date: o.time
|
|
|
|
? Quasar.utils.date.formatDate(
|
|
|
|
new Date(o.time * 1000),
|
|
|
|
'YYYY-MM-DD HH:mm'
|
|
|
|
)
|
|
|
|
: '',
|
|
|
|
expanded: false
|
|
|
|
})
|
2022-07-04 17:40:47 +03:00
|
|
|
}
|