File tree Expand file tree Collapse file tree 4 files changed +50
-1
lines changed Expand file tree Collapse file tree 4 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,8 @@ impl ToTransactionDataProtobuf for BatchTransactionData {
204204 let signed_transaction_bytes = transaction
205205 . to_signed_transaction_bytes ( )
206206 . expect ( "Inner transaction should be frozen and serializable" ) ;
207+
208+ println ! ( "Signed transaction bytes: {:?}" , signed_transaction_bytes) ;
207209 builder. transactions . push ( signed_transaction_bytes) ;
208210 }
209211
Original file line number Diff line number Diff line change @@ -543,6 +543,7 @@ impl<D: TransactionExecute> Transaction<D> {
543543
544544 /// Convenience method to mark a transaction as part of a batch transaction.
545545 /// The Transaction will be frozen and signed by the operator of the client.
546+ /// Per HIP-551, inner transactions use node account ID 0.0.0.
546547 ///
547548 /// # Errors
548549 ///
@@ -554,6 +555,8 @@ impl<D: TransactionExecute> Transaction<D> {
554555 ) -> crate :: Result < & mut Self > {
555556 self . require_not_frozen ( ) ;
556557 self . set_batch_key ( batch_key) ;
558+ // Set node account ID to 0.0.0 for batch transactions (as per HIP-551)
559+ self . node_account_ids ( [ crate :: AccountId :: new ( 0 , 0 , 0 ) ] ) ;
557560 self . freeze_with ( client) ?;
558561 self . sign_with_operator ( client)
559562 }
@@ -833,7 +836,7 @@ impl<D: TransactionExecute> Transaction<D> {
833836 sig_map : Some ( services:: SignatureMap { sig_pair : signatures. clone ( ) } ) ,
834837 } ;
835838 services:: Transaction {
836- signed_transaction_bytes : Vec :: new ( ) ,
839+ signed_transaction_bytes : signed_transaction . encode_to_vec ( ) ,
837840 body : None ,
838841 sigs : None ,
839842 body_bytes : signed_transaction. body_bytes ,
Original file line number Diff line number Diff line change 1+ use std:: str:: FromStr ;
2+ use hedera:: {
3+ AccountCreateTransaction ,
4+ BatchTransaction ,
5+ Hbar ,
6+ PrivateKey ,
7+ } ;
8+
9+ use crate :: common:: {
10+ setup_nonfree,
11+ TestEnvironment ,
12+ } ;
13+
14+ #[ tokio:: test]
15+ async fn can_execute_batch_transaction ( ) -> anyhow:: Result < ( ) > {
16+ let Some ( TestEnvironment { config : _, client } ) = setup_nonfree ( ) else {
17+ return Ok ( ( ) ) ;
18+ } ;
19+
20+ // Given
21+ let operator_key = PrivateKey :: from_str (
22+ "302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137"
23+ ) ?;
24+
25+ let account_key = PrivateKey :: generate_ed25519 ( ) ;
26+
27+ let mut inner_transaction = AccountCreateTransaction :: new ( ) ;
28+ inner_transaction
29+ . set_key_without_alias ( account_key. public_key ( ) )
30+ . initial_balance ( Hbar :: new ( 1 ) ) ;
31+
32+ // Use batchify to prepare the transaction
33+ inner_transaction. batchify ( & client, operator_key. public_key ( ) . into ( ) ) ?;
34+
35+ // When / Then
36+ let mut batch_transaction = BatchTransaction :: new ( ) ;
37+ batch_transaction. add_inner_transaction ( inner_transaction. into ( ) ) ?;
38+
39+ let tx_response = batch_transaction. execute ( & client) . await ?;
40+ let _tx_receipt = tx_response. get_receipt ( & client) . await ?;
41+
42+ Ok ( ( ) )
43+ }
Original file line number Diff line number Diff line change 11mod account;
22mod address_book;
3+ mod batch_transaction;
34mod client;
45mod common;
56mod contract;
You can’t perform that action at this time.
0 commit comments