looking good
This commit is contained in:
@@ -1214,39 +1214,47 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
|
|||||||
|
|
||||||
if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0)
|
if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0)
|
||||||
{
|
{
|
||||||
int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0;
|
if ( NOTARY_ADDRESS != "" )
|
||||||
for (size_t i = 0; i < tx.vin.size(); i++) {
|
{
|
||||||
uint256 hash; CTransaction txin; CTxDestination address;
|
int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0;
|
||||||
if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false))
|
for (size_t i = 0; i < tx.vin.size(); i++) {
|
||||||
{
|
uint256 hash; CTransaction txin; CTxDestination address;
|
||||||
if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) {
|
if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false))
|
||||||
// This means we sent the tx..
|
{
|
||||||
if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) {
|
if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) {
|
||||||
numvinIsOurs++;
|
// This means we sent the tx..
|
||||||
}
|
if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) {
|
||||||
}
|
numvinIsOurs++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No we know if it was a tx we sent, if it was all ours, we leave and let add to wallet.
|
|
||||||
fprintf(stderr, "address: %s sent vouts: %d\n",CBitcoinAddress(address).ToString().c_str(),numvinIsOurs);
|
|
||||||
if ( numvinIsOurs == 0 ) {
|
|
||||||
for (size_t i = 0; i < tx.vout.size() ; i++) {
|
|
||||||
CTxDestination address2;
|
|
||||||
if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) {
|
|
||||||
if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) {
|
|
||||||
// this should be a received tx..
|
|
||||||
numvoutIsOurs++;
|
|
||||||
totalvoutvalue = totalvoutvalue + tx.vout[i].nValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs);
|
// Now we know if it was a tx we sent, if it was all ours, we leave and let add to wallet.
|
||||||
// here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not.
|
fprintf(stderr, "address: %s sent vouts: %d\n",NOTARY_ADDRESS.c_str(),numvinIsOurs);
|
||||||
|
if ( numvinIsOurs == 0 ) {
|
||||||
|
for (size_t i = 0; i < tx.vout.size() ; i++) {
|
||||||
|
CTxDestination address2;
|
||||||
|
if ( ExtractDestination(tx.vout[i].scriptPubKey, address2)) {
|
||||||
|
if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) {
|
||||||
|
// this should be a received tx..
|
||||||
|
numvoutIsOurs++;
|
||||||
|
totalvoutvalue = totalvoutvalue + tx.vout[i].nValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(stderr, "address: %s received %ld sats from %d vouts.\n",NOTARY_ADDRESS.c_str(),totalvoutvalue,numvoutIsOurs);
|
||||||
|
// here we add calculation for number if vouts received, average size and determine if we accept them to wallet or not.
|
||||||
|
int64_t avgVoutSize = totalvoutvalue \ numvoutIsOurs;
|
||||||
|
if ( avgVoutSize < 100000000 ) {
|
||||||
|
// average vout size is less than 1 coin, we will ignore it
|
||||||
|
fprintf(stderr, "ignored: %d vouts average size of %ld sats.\n",numvoutIsOurs, avgVoutSize);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ( numvinIsOurs < tx.vin.size() ) {
|
||||||
} else if ( numvinIsOurs < tx.vin.size() ) {
|
// this means we were in a multi sig, we wil remove the utxo we spent from our wallet and do nothing else.
|
||||||
// this means we were in a multi sig, we wil remove the utxo we spent from our wallet and nothing else.
|
fprintf(stderr, "There are vins that are not ours, notarisation?\n");
|
||||||
fprintf(stderr, "There are vins that are not ours, notarisation?\n");
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CWalletTx wtx(this,tx);
|
CWalletTx wtx(this,tx);
|
||||||
|
|||||||
Reference in New Issue
Block a user