Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(XRP): Move Ripple blockchain to Rust #4250

Merged
merged 32 commits into from
Feb 7, 2025
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
db78bef
refactor(ripple): Add Ripple blockchain skeleton
satoshiotomakan Jan 28, 2025
c1b997c
refactor(ripple): Add Classic and X addresses
satoshiotomakan Jan 28, 2025
81bd052
refactor(ripple): Add more XAddress tests
satoshiotomakan Jan 29, 2025
d1cf952
refactor(ripple): Start working on transaction binary encoding
satoshiotomakan Jan 31, 2025
24fc460
refactor(ripple): Remove `serde_with` dependency
satoshiotomakan Jan 31, 2025
1d60c8f
refactor(ripple): Simplify `Result::tw_err` method
satoshiotomakan Jan 31, 2025
d4be95f
refactor(ripple): Implement `Encodable` for `XRPLTypes`
satoshiotomakan Jan 31, 2025
f62f210
refactor(ripple): Finish `Encoder`
satoshiotomakan Feb 1, 2025
7ca99a3
refactor(ripple): Add Transaction encoding from JSON test
satoshiotomakan Feb 2, 2025
5c5d882
refactor(ripple): Add `TransactionSigner`, `TransactionBuilder` from …
satoshiotomakan Feb 3, 2025
603cc94
refactor(ripple): Add `TrustSet`
satoshiotomakan Feb 4, 2025
6ac06f6
refactor(ripple): Add more Payment and TokenPayment tests
satoshiotomakan Feb 4, 2025
10674b9
refactor(ripple): Add `EscrowCreate`
satoshiotomakan Feb 4, 2025
c98707e
refactor(ripple): Add more `EscrowCreate` tests
satoshiotomakan Feb 4, 2025
a2268e1
refactor(ripple): Add `EscrowCancel`
satoshiotomakan Feb 4, 2025
7e4e7e6
refactor(ripple): Add `EscrowFinish`
satoshiotomakan Feb 4, 2025
c9aa577
refactor(ripple): Add `NFTokenBurn`
satoshiotomakan Feb 4, 2025
670e050
refactor(ripple): Add `NFTokenCreateOffer`
satoshiotomakan Feb 4, 2025
8f5c8cd
refactor(ripple): Add `NFTokenAcceptOffer`
satoshiotomakan Feb 4, 2025
c1f1b20
refactor(ripple): Add `NFTokenCancelOffer`
satoshiotomakan Feb 4, 2025
0717be8
refactor(ripple): Add `SourceTag`
satoshiotomakan Feb 5, 2025
2b981e5
refactor(ripple): Add transaction pre-image hashing and compiling
satoshiotomakan Feb 5, 2025
111643c
refactor(ripple): Add additional checks for XRP and IssuedCurrency am…
satoshiotomakan Feb 6, 2025
55b9b0f
refactor(ripple): Replace C++ implementation
satoshiotomakan Feb 6, 2025
1dc34a2
refactor(ripple): Minor change
satoshiotomakan Feb 6, 2025
c533885
refactor(ripple): Do not set `destinationTag` if `destination` is XAd…
satoshiotomakan Feb 6, 2025
0944d36
Merge branch 'master' into s/rust-xrp
satoshiotomakan Feb 6, 2025
d7970d2
refactor(ripple): Add fuzz tests
satoshiotomakan Feb 6, 2025
e553eac
refactor(ripple): Improve code coverage
satoshiotomakan Feb 6, 2025
8a2c059
refactor(ripple): Avoid bigdecimal duplication
satoshiotomakan Feb 6, 2025
66dbe62
refactor(ripple): Code improvements
satoshiotomakan Feb 6, 2025
dcf0e15
refactor(ripple): PR review comments
satoshiotomakan Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(ripple): Add SourceTag
satoshiotomakan committed Feb 5, 2025
commit 0717be8c88ea15ca3c4232b65f119db70afd508b
3 changes: 3 additions & 0 deletions rust/chains/tw_ripple/src/modules/protobuf_builder.rs
Original file line number Diff line number Diff line change
@@ -242,6 +242,9 @@ impl<'a> ProtobufBuilder<'a> {
.last_ledger_sequence(self.input.last_ledger_sequence)
.account_str(self.input.account.as_ref())?
.signing_pub_key(&signing_public_key);
if self.input.source_tag != 0 {
builder.source_tag(self.input.source_tag);
}
Ok(builder)
}

34 changes: 34 additions & 0 deletions rust/tw_tests/tests/chains/ripple/ripple_sign.rs
Original file line number Diff line number Diff line change
@@ -76,6 +76,40 @@ fn test_ripple_sign_xrp_payment_1() {
);
}

#[test]
fn test_ripple_sign_xrp_payment_with_source_tag() {
let private_key = "6da2485443b6856cef6414d45d880434371522cdceb5baf7bd7114e135d71424"
.decode_hex()
.unwrap();

let payment = Proto::OperationPayment {
amount_oneof: AmountType::amount(20000),
destination: "rp1ygcibUauhqdTrzo7y3QEJ3WL2sYnSpC".into(),
..Proto::OperationPayment::default()
};
let input = Proto::SigningInput {
fee: 12,
sequence: 93_933_582,
last_ledger_sequence: 93_938_147,
account: "rUFSa2D2JYGn5AiRZiQxSupZxV5KcHECG".into(),
private_key: private_key.into(),
operation_oneof: OperationType::op_payment(payment),
// `First Ledger` source tag.
source_tag: 74_920_348,
..Proto::SigningInput::default()
};

let mut signer = AnySignerHelper::<Proto::SigningOutput>::default();
let output = signer.sign(CoinType::XRP, input);
assert_eq!(output.error, SigningError::OK, "{}", output.error_message);

// https://xrpscan.com/tx/7ED44A908AD150EDEB3D022F3BF1B69A8C06999E143A914E0F3E7D59299693F1
assert_eq!(
output.encoded.to_hex(),
"1200002200000000230477319c240599500e201b059961e3614000000000004e2068400000000000000c732103df650aab92e1b0a95cbda6a5a0fc3bfdbe991901e5b1cdfcd238b769cb4934a77446304402204f104f0fcb8f6ab6d2de9051e99e15af285c6946f01ee53cc630b8ff00b70b840220015d1c5e09b398d830b1255358b4b504628628f36c4b82825442456d8fe3d1b98114023c2b9f15b95198d270b1bf92a4700c40272ca48314149c3d92a8c04140f028ebdb6fac746824384c94"
);
}

#[test]
fn test_ripple_sign_trust_set() {
let private_key = "8753e78ee2963f301f82e5eeab2754f593fc242ce94273dd2fb0684e3b0f2b91"
4 changes: 4 additions & 0 deletions src/proto/Ripple.proto
Original file line number Diff line number Diff line change
@@ -155,6 +155,10 @@ message SigningInput {

// Only used by tss chain-integration.
bytes public_key = 15;

// Arbitrary integer used to identify the reason for this payment, or a sender on whose behalf this transaction is made.
// Conventionally, a refund should specify the initial payment's SourceTag as the refund payment's DestinationTag.
uint32 source_tag = 25;
}

// Result containing the signed and encoded transaction.