* [Bitcoin-development] Multi Input/Output Transaction Problems
@ 2014-02-07 17:33 Crypto Fish
0 siblings, 0 replies; only message in thread
From: Crypto Fish @ 2014-02-07 17:33 UTC (permalink / raw)
To: bitcoin-development
[-- 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 --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-02-07 17:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-07 17:33 [Bitcoin-development] Multi Input/Output Transaction Problems Crypto Fish
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox