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

Sync Features #1

Merged
merged 56 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8f2fedd
add features
dangell7 Apr 5, 2024
f18b7c8
add fee fields
dangell7 Apr 6, 2024
aafaa62
add missing flags
dangell7 Apr 6, 2024
59813fa
remove canonical check
dangell7 Apr 6, 2024
120188b
Update fields.c
dangell7 Apr 19, 2024
a6bc6b4
update issue
dangell7 Apr 20, 2024
515c8b8
fix link error
dangell7 Apr 20, 2024
c391cac
Update fields.c
dangell7 Apr 24, 2024
5c182df
add xchain formatter
dangell7 Apr 24, 2024
b71bcc7
add read xchain
dangell7 Apr 24, 2024
1d13a28
add xchain formatter
dangell7 Apr 24, 2024
bf17f5a
add vector256
dangell7 May 7, 2024
f6b506c
update test cases
dangell7 May 7, 2024
97bb8e0
Delete tts.json
dangell7 May 7, 2024
935f95d
Update unit_tests.yml
dangell7 May 7, 2024
d249a18
update test cases
dangell7 May 7, 2024
e68020e
update tests
dangell7 May 7, 2024
7dd6b1e
Update flags.c
dangell7 May 7, 2024
d2a9b14
fix typo
dangell7 May 7, 2024
0f92c19
clang-format
dangell7 May 7, 2024
7f4ee18
fix imports
dangell7 May 7, 2024
fe8ba3b
add nftoken and clawback tests
dangell7 May 7, 2024
0325e69
update tests
dangell7 May 7, 2024
d0336e5
fix flags
dangell7 May 7, 2024
2d78b54
Update 01-basic.txt
dangell7 May 7, 2024
f407045
Update fields.c
dangell7 May 7, 2024
b0c249d
update tests
dangell7 May 7, 2024
d2bc515
Update test_tx.c
dangell7 May 7, 2024
4663f6b
Update 02-broker.txt
dangell7 May 7, 2024
374baf7
add amm tests
dangell7 May 7, 2024
facec8b
update amount
dangell7 May 7, 2024
75eff08
update amm flags
dangell7 May 7, 2024
3b18505
Update test_tx.c
dangell7 May 7, 2024
f04e492
update assets
dangell7 May 7, 2024
935cbbc
update amounts
dangell7 May 7, 2024
aa147d4
Update 02-min-max.txt
dangell7 May 7, 2024
a2d6592
Update 02-min-max.txt
dangell7 May 7, 2024
5bd0e96
fixup
dangell7 May 7, 2024
b420c80
update snapshots
dangell7 May 7, 2024
1b689f1
snapshots
dangell7 May 7, 2024
d30a774
remove unused variables
dangell7 May 7, 2024
78d4ded
Update flags.c
dangell7 May 7, 2024
7cdf49f
remove unused fields
dangell7 May 7, 2024
3de06ff
Update transaction_types.h
dangell7 May 7, 2024
3f713dc
Update utils.py
dangell7 May 7, 2024
8d14aa3
remove xchain & did
dangell7 Jun 6, 2024
5a8ca06
Merge remote-tracking branch 'upstream/develop' into sync-features
dangell7 Jun 6, 2024
5fbe491
clang-format
dangell7 Jun 6, 2024
7bcaa7f
update snapshots
dangell7 Jun 6, 2024
e257c61
snapshots
dangell7 Jun 6, 2024
88775a8
Revert "remove xchain & did"
dangell7 Jun 6, 2024
098bcb1
add dual currency test
dangell7 Jun 6, 2024
434ffd9
remove xchain & did
dangell7 Jun 6, 2024
a01b8df
snapshots
dangell7 Jun 6, 2024
0276063
clang-format
dangell7 Jun 6, 2024
3839eea
bump version
dangell7 Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:

- name: Run unit tests
run: |
make -C tests/build test
make -C tests/build test ARGS='-V -R test_tx'
16 changes: 10 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"files.associations": {
"*.h": "c"
},
"C_Cpp.clang_format_path": "/usr/bin/clang-format",
"editor.formatOnSave": true
}
"files.associations": {
"*.h": "c"
},
"C_Cpp.clang_format_path": "/usr/bin/clang-format",
"editor.formatOnSave": true,
"ledgerDevTools.appSettings": {
"selectedUseCase": "release",
"selectedDevice": "Nano S"
}
}
170 changes: 95 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,30 @@ and the examples below.
The XRP wallet app comes with the following features:

- Support for all transaction types:
- AMMBid
- AMMCreate
- AMMDelete
- AMMDeposit
- AMMVote
- AMMWithdrawal
- AccountSet
- AccountDelete
- CheckCancel
- CheckCash
- CheckCreate
- Clawback
- DepositPreauth
- DIDDelete
- DIDSet
- DepositPreauth
- EscrowCancel
- EscrowCreate
- EscrowFinish
- NFTokenAcceptOffer
- NFTokenBurn
- NFTokenCancelOffer
- NFTokenCreateOffer
- NFTokenMint
- OfferCancel
- OfferCreate
- Payment
Expand All @@ -36,7 +51,17 @@ The XRP wallet app comes with the following features:
- PaymentChannelFund
- SetRegularKey
- SignerListSet
- TicketCancel
- TicketCreate
- TrustSet
- XChainAccountCreateCommit
- XChainAddAccountCreateAttestation
- XChainAddClaimAttestation
- XChainClaim
- XChainCommit
- XChainCreateBridge
- XChainCreateClaimID
- XChainModifyBridge
- Support for all transaction common fields such as memos
- Support for issued assets such as SOLO, stocks and ETFs
- Support for signing on behalf of others
Expand Down Expand Up @@ -93,50 +118,49 @@ An example of a basic payment transaction using this library is shown below:
import Transport from "@ledgerhq/hw-transport-node-hid";
// import Transport from "@ledgerhq/hw-transport-u2f"; // for browser
import Xrp from "@ledgerhq/hw-app-xrp";
import { encode } from 'ripple-binary-codec';
import { encode } from "ripple-binary-codec";

function establishConnection() {
return Transport.create()
.then(transport => new Xrp(transport));
return Transport.create().then((transport) => new Xrp(transport));
}

function fetchAddress(xrp) {
return xrp.getAddress("44'/144'/0'/0/0").then(deviceData => {
return {
xrp,
address: deviceData.address,
publicKey: deviceData.publicKey.toUpperCase()
}
});
return xrp.getAddress("44'/144'/0'/0/0").then((deviceData) => {
return {
xrp,
address: deviceData.address,
publicKey: deviceData.publicKey.toUpperCase(),
};
});
}

function signTransaction(context, transaction) {
const preparedTransaction = {
Account: context.address,
SigningPubKey: context.publicKey,
...transaction
};
const preparedTransaction = {
Account: context.address,
SigningPubKey: context.publicKey,
...transaction,
};

const transactionBlob = encode(preparedTransaction);
const transactionBlob = encode(preparedTransaction);

console.log('Sending transaction to device for approval...');
return context.xrp.signTransaction("44'/144'/0'/0/0", transactionBlob);
console.log("Sending transaction to device for approval...");
return context.xrp.signTransaction("44'/144'/0'/0/0", transactionBlob);
}

const transactionJSON = {
TransactionType: "Payment",
Destination: "rTooLkitCksh5mQa67eaa2JaWHDBnHkpy",
Amount: "1000000",
Fee: "15",
Flags: 2147483648,
Sequence: 57,
TransactionType: "Payment",
Destination: "rTooLkitCksh5mQa67eaa2JaWHDBnHkpy",
Amount: "1000000",
Fee: "15",
Flags: 2147483648,
Sequence: 57,
};

establishConnection()
.then(xrp => fetchAddress(xrp))
.then(context => signTransaction(context, transactionJSON))
.then(signature => console.log(`Signature: ${signature}`))
.catch(e => console.log(`An error occurred (${e.message})`));
.then((xrp) => fetchAddress(xrp))
.then((context) => signTransaction(context, transactionJSON))
.then((signature) => console.log(`Signature: ${signature}`))
.catch((e) => console.log(`An error occurred (${e.message})`));
```

### Advanced Usage
Expand All @@ -151,64 +175,60 @@ with a signature of the Ledger device is shown below (uses imports and functions

```javascript
const transactionJSON = {
Account: "r4PCuDkjuV2e23xVP8ChkVxo1aG2Ufpkjb",
TransactionType: "Payment",
Destination: "rTooLkitCksh5mQa67eaa2JaWHDBnHkpy",
Amount: "1000000",
Fee: "15",
Flags: 2147483648,
Sequence: 47,
SigningPubKey: "" // Must be blank
Account: "r4PCuDkjuV2e23xVP8ChkVxo1aG2Ufpkjb",
TransactionType: "Payment",
Destination: "rTooLkitCksh5mQa67eaa2JaWHDBnHkpy",
Amount: "1000000",
Fee: "15",
Flags: 2147483648,
Sequence: 47,
SigningPubKey: "", // Must be blank
};

// Sourced externally from other signing parties, replace "..." with actual values.
const otherSigners = [
{
Signer: {
Account: "...",
SigningPubKey: "...",
TxnSignature: "..."
}
{
Signer: {
Account: "...",
SigningPubKey: "...",
TxnSignature: "...",
},
},
{
Signer: {
Account: "...",
SigningPubKey: "...",
TxnSignature: "...",
},
{
Signer: {
Account: "...",
SigningPubKey: "...",
TxnSignature: "..."
}
}
},
];

function retrieveSignerData(transaction) {
return establishConnection()
.then(xrp => fetchAddress(xrp))
.then(context => {
return signTransaction(context, transaction)
.then(signature => {
return {
Signer: {
Account: context.account,
SigningPubKey: context.publicKey,
TxnSignature: signature.toUpperCase()
}
}
});
})
.catch(e => console.log(`An error occurred (${e.message})`));
return establishConnection()
.then((xrp) => fetchAddress(xrp))
.then((context) => {
return signTransaction(context, transaction).then((signature) => {
return {
Signer: {
Account: context.account,
SigningPubKey: context.publicKey,
TxnSignature: signature.toUpperCase(),
},
};
});
})
.catch((e) => console.log(`An error occurred (${e.message})`));
}

retrieveSignerData(transactionJSON)
.then(signer => {
return {
...transactionJSON,
Signers: [
...otherSigners,
signer
]
}
})
.then(transaction => console.log(transaction))
.catch(e => console.log(`An error occurred (${e.message})`));
.then((signer) => {
return {
...transactionJSON,
Signers: [...otherSigners, signer],
};
})
.then((transaction) => console.log(transaction))
.catch((e) => console.log(`An error occurred (${e.message})`));
```

### Additional Notes
Expand Down
2 changes: 1 addition & 1 deletion src/xrp/amount.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static int format_xrp(uint64_t amount, field_value_t *dst) {
return 0;
}

static bool is_all_zeros(const uint8_t *data, uint8_t length) {
bool is_all_zeros(const uint8_t *data, uint8_t length) {
for (size_t i = 0; i < length; ++i) {
if (data[i] != 0) {
return false;
Expand Down
Loading
Loading