Skip to content

smite-ir: add CreateFundingTransaction IR operation#90

Open
NishantBansal2003 wants to merge 1 commit into
morehouse:masterfrom
NishantBansal2003:funding-tx-ir
Open

smite-ir: add CreateFundingTransaction IR operation#90
NishantBansal2003 wants to merge 1 commit into
morehouse:masterfrom
NishantBansal2003:funding-tx-ir

Conversation

@NishantBansal2003
Copy link
Copy Markdown
Contributor

This commit adds the CreateFundingTransaction IR operation. For this, a new VariableType, 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 exchange channel_ready messages

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Copy link
Copy Markdown
Owner

@morehouse morehouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread smite-ir/src/operation.rs
Self::DerivePoint => vec![VariableType::PrivateKey],
Self::ExtractAcceptChannel(_) => vec![VariableType::AcceptChannel],
Self::SendMessage => vec![VariableType::Message],
Self::CreateFundingTransaction => vec![
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the ordering is inconsistent in some places -- in general CreateFundingTransaction comes right after ExtractAcceptChannel, but not here

Comment thread smite-ir/src/operation.rs
/// 1: `acceptor_funding_pubkey` (`Point`)
/// 2: `funding_satoshis` (`Amount`)
/// 3: `feerate_per_kw` (`FeeratePerKw`)
CreateFundingTransaction,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should we call it BuildFundingTransaction for consistency with similar operations?

Comment thread smite-ir/src/tests.rs
}

#[test]
fn validate_rejects_create_funding_transaction_with_wrong_input_type() {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +1251 to +1280
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],
},
];
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be generated by a helper function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants