Blockchain Hyperledger private key not able to send coins

0 votes

I am using the following code (this is the partial code):

bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, int64_t nFees, CTransaction& txNew, CKey& key)
{
                if(whichType == TX_SCRIPTHASH){//pay to stealth type if exist
//                    std::set<CStealthAddress>::iterator it;
//                    for (it = stealthAddresses.begin(); it != stealthAddresses.end(); ++it){
//                    if(!keystore.GetCScript(stealthAddresses.begin()->Encoded(), key)){
//                        if (fDebug && GetBoolArg("-printcoinstake"))
//                            printf("CreateCoinStake : failed to get key for kernel type=%d\n", whichType);
//                        break;  // unable to find hash of the first stealth address
//                    }

//                    }
                    return true;
                } else {//no stealth address found pay to
    
    
    // Set output amount
    if (txNew.vout.size() == 3)
    {
        txNew.vout[1].nValue = (nCredit / 2 / CENT) * CENT;
        txNew.vout[2].nValue = nCredit - txNew.vout[1].nValue;
    }
    else
        txNew.vout[1].nValue = nCredit;

    // Sign
    int nIn = 0;
    BOOST_FOREACH(const CWalletTx* pcoin, vwtxPrev)
    {
        if (!SignSignature(*this, *pcoin, txNew, nIn++))
            return error("CreateCoinStake : failed to sign coinstake");
    }

    // Limit size
    unsigned int nBytes = ::GetSerializeSize(txNew, SER_NETWORK, PROTOCOL_VERSION);
    if (nBytes >= MAX_BLOCK_SIZE_GEN/5)
        return error("CreateCoinStake : exceeded coinstake size limit");

    // Successfully generated coinstake
    return true;
}

when I send it the rewards, they go to a pub address

Sep 14, 2018 in Blockchain by slayer
• 29,370 points
586 views

1 answer to this question.

0 votes

From the code you posted,

if(whichType == TX_SCRIPTHASH){//pay to stealth type if exist
//                    std::set<CStealthAddress>::iterator it;
//                    for (it = stealthAddresses.begin(); it != stealthAddresses.end(); ++it){
//                    if(!keystore.GetCScript(stealthAddresses.begin()->Encoded(), key)){
//                        if (fDebug && GetBoolArg("-printcoinstake"))
//                            printf("CreateCoinStake : failed to get key for kernel type=%d\n", whichType);
//                        break;  // unable to find hash of the first stealth address
//                    }

//                    }

All of this code is commented out. Remove the leading //'s and it should work.

answered Sep 14, 2018 by digger
• 26,740 points

Related Questions In Blockchain

0 votes
1 answer
0 votes
1 answer

Not able to send payments using Blockchain API.

Try the following code. It should help ...READ MORE

answered Jul 31, 2018 in Blockchain by slayer
• 29,370 points
622 views
0 votes
1 answer

Not able to send ethers in private ethereum network

Your account is locked by default due ...READ MORE

answered Jan 9, 2019 in Blockchain by Omkar
• 69,220 points
1,110 views
–1 vote
1 answer

Not able to create new account in geth for private ethereum blockchain

personal.newAccount() is not a default geth method. This ...READ MORE

answered Jan 17, 2019 in Blockchain by Omkar
• 69,220 points
3,795 views
0 votes
1 answer

How to add Bitcoin as currency for my website?

You cannot use BTC as the currency ...READ MORE

answered Aug 17, 2018 in Blockchain by slayer
• 29,370 points
1,056 views
0 votes
1 answer
0 votes
1 answer

How to compute SHA256 hash for bitcoin header

header_hex = "02000000aaf8ab82362344f49083ee4edef795362cf135293564c4070000000000000000c009bb6222e9bc4cdb8f26b2e8a2f8d163509691a4038fa692abf9a474c9b21476800755c02e17181fe6c1c3" # Decode header hex into ...READ MORE

answered Aug 31, 2018 in Blockchain by digger
• 26,740 points
1,482 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,923 views
0 votes
1 answer

Not able to generate WIF from extended private key

I found the answer to this in the ...READ MORE

answered Aug 29, 2018 in Blockchain by digger
• 26,740 points
1,234 views
0 votes
1 answer

Hyperledger Fabric CA "Failed to get user: User not found"

The problem could be because of the ...READ MORE

answered Jul 23, 2018 in Blockchain by digger
• 26,740 points
2,510 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP