Skip to content

Commit

Permalink
fix: p2wpkh utxo filter
Browse files Browse the repository at this point in the history
  • Loading branch information
7-of-9 committed Sep 30, 2021
1 parent de8f898 commit ebc6254
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
15 changes: 14 additions & 1 deletion app-worker/worker-blockbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ function getAddressFull_Blockbook_v3(wallet, asset, address, utxo_mempool_spentT
// axios.get(configExternal.walletExternal_config[symbol].api.utxo(address))
// .then(async (utxoData) => {
isosocket_send_Blockbook(symbol, 'getAccountUtxo', {descriptor: address} , async (utxosData) => {

// if (address === 'bc1qkdnsl2aulf4ktfeyfsvysgknfsmpew77cqahqy') {
// debugger
// }

if (!utxosData) { utilsWallet.error(`## getAddressFull_Blockbook_v3 ${symbol} ${address} - no utxosData`); reject(); return }
if (utxosData.error) {
Expand All @@ -91,6 +95,10 @@ function getAddressFull_Blockbook_v3(wallet, asset, address, utxo_mempool_spentT
isosocket_send_Blockbook(symbol, 'getTransactionSpecific', { txid: utxo.txid } , async (utxoSpecificData) => {
//utilsWallet.debug(`blockbook tx ${utxo.txid} for ${address} utxoSpecificData`, utxoSpecificData)

// if (utxo.txid === '782fd42cda8112201f87f5f2a5721a664763d9df4b43d80a3dbb6de511379cce') {
// debugger
// }

if (!utxoSpecificData) { utilsWallet.error(`## getAddressFull_Blockbook_v3 ${symbol} ${utxo.txid} - no utxoSpecificData!`); resolveSpecificUtxoOp([]); return }
if (utxoSpecificData.error) {
//debugger
Expand All @@ -113,7 +121,12 @@ function getAddressFull_Blockbook_v3(wallet, asset, address, utxo_mempool_spentT
// DMS: we *include* OP_RETURN outputs - we'll use the op_return data to allow beneficiary & benefactor to create the locking script (i.e. the address)
// for the "protected" non-standard P2SH(DSIG/CLTV) outputs...
//
if ((utxo.vout == utxoSpecific.n && (utxoSpecific.scriptPubKey.addresses !== undefined && utxoSpecific.scriptPubKey.addresses.includes(address)))
if ((utxo.vout == utxoSpecific.n
&& (
(utxoSpecific.scriptPubKey.addresses !== undefined && utxoSpecific.scriptPubKey.addresses.includes(address)) // p2sh
|| (utxoSpecific.scriptPubKey.address !== undefined && utxoSpecific.scriptPubKey.address == address && utxoSpecific.scriptPubKey.type == 'witness_v0_keyhash') // p2wpkh
)
)
|| (utxoSpecific.scriptPubKey.addresses === undefined && utxoSpecific.scriptPubKey.type === "nulldata") // op_return
) {
resolveSpecificUtxos.push({
Expand Down
8 changes: 4 additions & 4 deletions config/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ var supportedWalletTypes = [ // use walletsMeta keys for this list
var walletsMeta = {
// utxo's
'btc(s2)': { // p2wpkh "native" Bech32 unwrapped segwit btc
core_asset: true,
core_asset: true,
name: 'btc(s2)',
use_BBv3: true,
web: 'https://bitcoin.org/',
priceSource: PRICE_SOURCE_CRYPTOCOMPARE,
type: WALLET_TYPE_UTXO,
addressType: ADDRESS_TYPE_BECH32,
addressType: ADDRESS_TYPE_BECH32,
symbol: 'BTC_SEG2',
displayName: 'Bitcoin',
desc: 'bc-addr Bech32 (P2WPKH)', //'SegWit (P2WPKH) Bech32',
Expand All @@ -147,7 +147,7 @@ var walletsMeta = {
tradingViewSymbol: "BITFINEX:BTCUSD",
},
'btc(s)': { // p2sh-wrapped segwit btc
core_asset: true,
core_asset: true, // TODO: deprecate - make this the non-core (i.e. migrate p2sh P_OP... to bech32)
name: 'btc(s)',
use_BBv3: true,
web: 'https://bitcoin.org/',
Expand All @@ -156,7 +156,7 @@ var walletsMeta = {
addressType: ADDRESS_TYPE_BTC,
symbol: 'BTC_SEG',
OP_CLTV: true,
displayName: 'Bitcoin',
displayName: 'Bitcoin',
desc: '3-addr P2SH(P2WPKH)',
displaySymbol: 'BTC',
imageUrl: 'img/asset-icon/btc_seg2.png',
Expand Down

0 comments on commit ebc6254

Please sign in to comment.