I am starting to test throwing some basic external state contracts into the testnet blockchain. I ran into a minor issue with testing, but I think it's due to sequence number not working quite like I thought.
I have TX1, TX1Refund, TX2, TX2Refund, and ContractTX. TX1 comes from user 1, TX2 comes from user 2. TXRefund spends with a timelock of currenttime+60 minutes and has a sequencenumber of 1 for the input it is associated with. ContractTX takes TX1 and TX2 as inputs, but with a MAX sequence number and no timelock.
I have not been using bitcoinJ to propogate transactions, but instead sending them through the bitcoin-qt console using "sendrawtransaction". If I send the refunds, I cannot submit the contract. Once sequence number is fully supported, I should be able to do this.
What my understanding of the situation, without getting into the bitcoin-qt code, is that the timelocked transactions (refunds) are held in the mempool (I can see this with getrawmempool), and since sequence number is not being honored, it sees it as a double spend if I try to submit the ContractTx, so it rejects the transaction and does not relay it. The timelocked transactions are held in the mempool but not relayed. I likely could send a raw transaction of the contract on another client that has not seen the refunds, since they aren't being relayed (until lock time).
This is unfortunate, but not a roadblock. I can just make the app not submit refunds until after the lock time, thus not making it look like a double-spend.
Is my understanding of what is happening correct?
The worst I can think of that will happen is someone will somehow get the contract refund tx (which expires some time after the nonces should have been published) and gets that transaction into the mempool of a lot of miners, and it blocks the correct user from redeeming the transaction. Probably not a concern.
BTW, here are some sample transactions in the chain if anyone is curious:
Funding Transaction 1 - Funds from wallet 1 into multisig address
Funding Transaction 2 - Funds from wallet 2 into multisig address
Contract Transaction - Spends funding inputs to a redeemable location by either a) wallet 1 once nonce1 is known, b) wallet 2 ocne nonce2 is known, or c) wallet 1 + wallet2 at any time.
Contract Refund TX - I made a mistake on this one and accidentally divided the fee wrong and ended up paying a huge fee and only refunding half the funding amounts, oops! This has been fixed. This is an example of spending with both signatures.