smite-ir: add CreateFundingTransaction IR operation#90
smite-ir: add CreateFundingTransaction IR operation#90NishantBansal2003 wants to merge 1 commit into
Conversation
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
morehouse
left a comment
There was a problem hiding this comment.
Code looks good.
What's your vision for fitting CreateFundingTransaction into the funding flow?
I'm guessing we'll implement a BroadcastTx operation next that takes a FundingTransaction as an input? Does it make sense to have separate operations, or should we just combine into a single CreateAndBroadcastFundingTx? Or would it make sense to have a generic Transaction variable type instead of the more specific FundingTransaction?
| Self::DerivePoint => vec![VariableType::PrivateKey], | ||
| Self::ExtractAcceptChannel(_) => vec![VariableType::AcceptChannel], | ||
| Self::SendMessage => vec![VariableType::Message], | ||
| Self::CreateFundingTransaction => vec![ |
There was a problem hiding this comment.
Nit: the ordering is inconsistent in some places -- in general CreateFundingTransaction comes right after ExtractAcceptChannel, but not here
| /// 1: `acceptor_funding_pubkey` (`Point`) | ||
| /// 2: `funding_satoshis` (`Amount`) | ||
| /// 3: `feerate_per_kw` (`FeeratePerKw`) | ||
| CreateFundingTransaction, |
There was a problem hiding this comment.
Nit: should we call it BuildFundingTransaction for consistency with similar operations?
| } | ||
|
|
||
| #[test] | ||
| fn validate_rejects_create_funding_transaction_with_wrong_input_type() { |
There was a problem hiding this comment.
Nit: this test is hard to follow. I think it would be easier to understand if it were split into 4 tests with a helper function
| let instrs = vec![ | ||
| Instruction { | ||
| operation: Operation::LoadPrivateKey([0x11; 32]), | ||
| inputs: vec![], | ||
| }, | ||
| Instruction { | ||
| operation: Operation::DerivePoint, | ||
| inputs: vec![0], | ||
| }, | ||
| Instruction { | ||
| operation: Operation::LoadPrivateKey([0x22; 32]), | ||
| inputs: vec![], | ||
| }, | ||
| Instruction { | ||
| operation: Operation::DerivePoint, | ||
| inputs: vec![2], | ||
| }, | ||
| Instruction { | ||
| operation: Operation::LoadAmount(10_000_000), | ||
| inputs: vec![], | ||
| }, | ||
| Instruction { | ||
| operation: Operation::LoadFeeratePerKw(15_000), | ||
| inputs: vec![], | ||
| }, | ||
| Instruction { | ||
| operation: Operation::CreateFundingTransaction, | ||
| inputs: vec![1, 3, 4, 5], | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
This could be generated by a helper function.
This commit adds the
CreateFundingTransactionIR operation. For this, a newVariableType,FundingTransaction, has been added. This is required because we need the funding transaction after receiving the funding signed message so that we can broadcast the transaction and exchangechannel_readymessages