Uh oh!
There was an error while loading. Please reload this page.
Conversation
thefallentree
commented
Nov 14, 2019
I think you didn’t ran bindgen |
| struct CDevAccountResource account_resource_from_lcs(const uint8_t *buf, size_t len); | ||
| void account_resource_free(struct CDevAccountResource *point); | ||
| uint8_t* lcs_signed_transaction(uint64_t sender[32], uint64_t receiver[32], uint64_t sequence, uint64_t num_coins, uint64_t max_gas_amount, uint64_t gas_unit_price, uint64_t expiration_time_millis, uint8_t* private_key_bytes); |
There was a problem hiding this comment.
can't just return an pointer , the user will have no means to free the memory. Instead we need to let user pass in an pre-allocated buffer pointer, with size, and we have to return an error if size is too small
Uh oh!
There was an error while loading. Please reload this page.
4277179 to
460e797Compare| void account_resource_free(struct CDevAccountResource *point); | ||
| void lcs_signed_transaction(const uint8_t sender[32], const uint8_t receiver[32], uint64_t sequence, uint64_t num_coins, uint64_t max_gas_amount, uint64_t gas_unit_price, uint64_t expiration_time_millis, const uint8_t* private_key_bytes, uint8_t** buf, size_t* len); | ||
| void free_txn(uint8_t** buf); |
There was a problem hiding this comment.
we should name it as
libra_signed_transcation_build() and libra_signed_transcation_free() for consistency (I'm doing it for AccountResource too)
| 987654321, | ||
| 123456789, | ||
| ByteArray::new(vec![1,2,3,4]), | ||
| ByteArray::new(vec![1, 2, 3, 4]), |
Uh oh!
There was an error while loading. Please reload this page.
| // generate key pair | ||
| let mut seed: [u8; 32] = [0u8; 32]; | ||
| seed[..4].copy_from_slice(&[1, 2, 3, 4]); |
211ce98 to
531b303Compare| [dev-dependencies] | ||
| transaction-builder = {git = "https://github.com/libra/libra.git", branch = "testnet" } | ||
| lcs = { git = "https://github.com/libra/libra.git", branch = "testnet", package = "libra-canonical-serialization" } | ||
| rand = "0.6.5" |
There was a problem hiding this comment.
looks like this is only used in test ? so it should be in dev-dependencies
| struct CDevAccountResource account_resource_from_lcs(const uint8_t *buf, size_t len); | ||
| void account_resource_free(struct CDevAccountResource *point); | ||
| /// To get the serialized transaction in a memory safe manner, the client needs to pass in a pointer to a pointer to the allocated memory in rust |
There was a problem hiding this comment.
we should use doxgen tags (all tools will be able to use it, including automatically generating html docs)
https://www.rosettacommons.org/docs/latest/development_documentation/tutorials/doxygen-tips#common-doxygen-tags
specifically, mark the params with @params[in] @params[in/out] etc will be very useful.
Also, you need to say user take ownership of pointer returned by *buf, which needs to be freeed by libra_signed_transcation_free
| ) | ||
| ); | ||
| } | ||
| extern "C" { |
There was a problem hiding this comment.
Does these actually works other than just generate warnings? Myabe we should just put the data types in data.rs instead.
There was a problem hiding this comment.
we could do that and not generate functions
| pub mod account_resource; | ||
| mod transaction; |
| buf: *mut *mut u8, | ||
| len: *mut usize, | ||
| ) { | ||
| let sender_buf: &[u8] = unsafe { slice::from_raw_parts(sender, ADDRESS_LENGTH) }; |
There was a problem hiding this comment.
no need for &[u8] I think, rust will figure it out.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| #[no_mangle] | ||
| pub unsafe extern "C" fn libra_signed_transaction_free(buf: *mut *mut u8) { | ||
| libc::free(*buf as *mut libc::c_void); |
upgrade to latest testnet, fix account role missing fields
This PR provides an API to get a serialized SignedTransaction type given the transaction metadata and a private key in bytes.