public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: Crypto Fish <cryptofish82@gmail•com>
To: bitcoin-development@lists•sourceforge.net
Subject: [Bitcoin-development] Multi Input/Output Transaction Problems
Date: Fri, 7 Feb 2014 10:33:12 -0700	[thread overview]
Message-ID: <CALDrD5O0bn1xchKH=vs0FNDcdL24uUm3qs+1ERj24zw_VtVsHQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2493 bytes --]

So, I'm having some problems getting a multi input/multi output transaction
working. My code below works with 1 input and 2 output, but when adding
more inputs/outputs the transaction gets rejected. I'm sure whatever I'm
doing wrong in pretty simple, any ideas?

Code works for this (1 input, 2 outputs):

CTransaction(hash=01a3204517476812df2c2f77735a72a6d3e7eb8b9a5d5330ca433dd875fc4c3c,
ver=1, vin.size=2, vout.size=4, nLockTime=0)

CTxIn(COutPoint(6ee4049d6c75d6450e961446d28760207bd7036e2aa692afb80bb34245d3df84,
0), scriptSig=304502204cdfd276ff9c53bb)
    CTxOut(nValue=4.00000000, scriptPubKey=OP_DUP OP_HASH160 b07e181ce438)
    CTxOut(nValue=1.00000000, scriptPubKey=OP_DUP OP_HASH160 bf7484e469c8)

Code doesn't work for this (2 input, 4 outputs):

CTransaction(hash=01a3204517476812df2c2f77735a72a6d3e7eb8b9a5d5330ca433dd875fc4c3c,
ver=1, vin.size=2, vout.size=4, nLockTime=0)

CTxIn(COutPoint(6ee4049d6c75d6450e961446d28760207bd7036e2aa692afb80bb34245d3df84,
1), scriptSig=304502204aef3f393c273835)

CTxIn(COutPoint(6ee4049d6c75d6450e961446d28760207bd7036e2aa692afb80bb34245d3df84,
0), scriptSig=304502204cdfd276ff9c53bb)
    CTxOut(nValue=4.00000000, scriptPubKey=OP_DUP OP_HASH160 bf7484e469c8)
    CTxOut(nValue=491.00000000, scriptPubKey=OP_DUP OP_HASH160 0796b7f3430f)
    CTxOut(nValue=4.00000000, scriptPubKey=OP_DUP OP_HASH160 b07e181ce438)
    CTxOut(nValue=1.00000000, scriptPubKey=OP_DUP OP_HASH160 bf7484e469c8)

Pseudo code showing working transaction:

    // These are how the vout's are made
    CScript scriptPubKey;
    scriptPubKey.SetDestination(address);
    CScript s;
    s << OP_DUP << OP_HASH160 << scriptPubKey.GetID() << OP_EQUALVERIFY <<
OP_CHECKSIG;

    CTxOut out(nValue, s);

    ---------------


    CTransaction txNew;
    txNew.vin.clear();
    txNew.vout.clear();

    // vin and vout are already populated
    for(unsigned int i = 0; i < vout.size(); i++){
        txNew.vout.push_back(vout[i]);
    }

    //add all vins
    for(unsigned int i = 0; i < vin.size(); i++){
        txNew.vin.push_back(vin[i]);
    }

    //add all vins
    for(unsigned int i = 0; i < vin.size(); i++){
        // this is signed with 2 separate keys for each vin
        if(!SignSignature(*keystore, prevPubKey, txNew, i,
int(SIGHASH_ALL|SIGHASH_ANYONECANPAY)))
            printf('signing failed!\n');

        // I was told I might need to serialize the inputs? Not sure how
that would work
    }

    RelayTransaction(txNew, txNew.Hash());


---

CryptoFish

[-- Attachment #2: Type: text/html, Size: 6494 bytes --]

                 reply	other threads:[~2014-02-07 17:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALDrD5O0bn1xchKH=vs0FNDcdL24uUm3qs+1ERj24zw_VtVsHQ@mail.gmail.com' \
    --to=cryptofish82@gmail$(echo .)com \
    --cc=bitcoin-development@lists$(echo .)sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox