multiprocess: Add serialization code for CTransaction

Add support for passing CTransaction and CTransactionRef types to IPC
functions.

These types can't be passed currently because IPC serialization code currently
only supports deserializing types that have an Unserialize() method, which
CTransaction does not, because it is supposed to represent immutable
transactions. Work around this by adding a CustomReadField overload that will
call CTransaction's deserialize_type constructor.

These types also can't be passed currently because serializing transactions
requires TransactionSerParams to be set. Fix this by setting TX_WITH_WITNESS as
default serialization parameters for IPC code.
This commit is contained in:
Russell Yanofsky
2017-12-05 15:57:12 -05:00
parent 69dfeb1876
commit 095286f790
4 changed files with 50 additions and 3 deletions

View File

@@ -88,6 +88,15 @@ void IpcPipeTest()
UniValue uni2{foo->passUniValue(uni1)};
BOOST_CHECK_EQUAL(uni1.write(), uni2.write());
CMutableTransaction mtx;
mtx.version = 2;
mtx.nLockTime = 3;
mtx.vin.emplace_back(txout1);
mtx.vout.emplace_back(COIN, CScript());
CTransactionRef tx1{MakeTransactionRef(mtx)};
CTransactionRef tx2{foo->passTransaction(tx1)};
BOOST_CHECK(*Assert(tx1) == *Assert(tx2));
// Test cleanup: disconnect pipe and join thread
disconnect_client();
thread.join();