Skip to content

Commit 7004b90

Browse files
committed
[BDAP] Add IsBDAP and IsData methods to tx output
1 parent 91adeec commit 7004b90

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

src/primitives/transaction.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,36 @@ CTxOut::CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn, int nRoundsIn)
5858
nRounds = nRoundsIn;
5959
}
6060

61+
bool CTxOut::IsBDAP() const
62+
{
63+
opcodetype opcode;
64+
CScript::const_iterator pc = scriptPubKey.begin();
65+
if (!scriptPubKey.GetOp(pc, opcode))
66+
return false;
67+
if (opcode < OP_1 || opcode > OP_16)
68+
return false;
69+
70+
int op = CScript::DecodeOP_N(opcode);
71+
if (op == OP_BDAP_NEW || op == OP_BDAP_DELETE || op == OP_BDAP_EXPIRE || op == OP_BDAP_MODIFY || op == OP_BDAP_MOVE)
72+
return true;
73+
74+
return false;
75+
}
76+
77+
bool CTxOut::IsData() const
78+
{
79+
opcodetype opcode;
80+
CScript::const_iterator pc = scriptPubKey.begin();
81+
if (!scriptPubKey.GetOp(pc, opcode))
82+
return false;
83+
84+
int op = CScript::DecodeOP_N(opcode);
85+
if (op == OP_RETURN)
86+
return true;
87+
88+
return false;
89+
}
90+
6191
std::string CTxOut::ToString() const
6292
{
6393
return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, HexStr(scriptPubKey).substr(0, 30));

src/primitives/transaction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ class CTxOut
218218
return !(a == b);
219219
}
220220

221+
bool IsBDAP() const;
222+
bool IsData() const;
223+
221224
std::string ToString() const;
222225
};
223226

src/wallet/wallet.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,6 +2908,9 @@ void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed,
29082908
if (!found)
29092909
continue;
29102910

2911+
if (pcoin->tx->vout[i].IsBDAP())
2912+
continue;
2913+
29112914
isminetype mine = IsMine(pcoin->tx->vout[i]);
29122915
if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
29132916
(!IsLockedCoin((*it).first, i) || nCoinType == ONLY_1000) &&

0 commit comments

Comments
 (0)