diff --git a/docs/index.md b/docs/index.md index 6f752ad7..dd096dd3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -479,7 +479,8 @@ See [Transaction Types](#transaction-types) for a description. Name | Type | Description ---- | ---- | ----------- -defaultRipple | boolean | *Optional* Enable [rippling](https://ripple.com/knowledge_center/understanding-the-noripple-flag/) on this account’s trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3)) +defaultRipple | boolean | *Optional* Enable [rippling](https://ripple.com/build/understanding-the-noripple-flag/) on this account’s trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3)) +depositAuth | boolean | *Optional* Enable [Deposit Authorization](https://ripple.com/build/deposit-authorization/) on this account. If set, transactions cannot send value of any kind to this account unless the sender of those transactions is the account itself. (Requires the [DepositAuth amendment](https://ripple.com/build/known-amendments/#depositauth)) disableMasterKey | boolean | *Optional* Disallows use of the master key to sign transactions for this account. disallowIncomingXRP | boolean | *Optional* Indicates that client applications should not send XRP to this account. Not enforced by rippled. domain | string | *Optional* The domain that owns this account, as a hexadecimal string representing the ASCII for the domain in lowercase. @@ -2718,7 +2719,8 @@ This method returns a promise that resolves with an array of objects with the fo Name | Type | Description ---- | ---- | ----------- -defaultRipple | boolean | *Optional* Enable [rippling](https://ripple.com/knowledge_center/understanding-the-noripple-flag/) on this account’s trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3)) +defaultRipple | boolean | *Optional* Enable [rippling](https://ripple.com/build/understanding-the-noripple-flag/) on this account’s trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3)) +depositAuth | boolean | *Optional* Enable [Deposit Authorization](https://ripple.com/build/deposit-authorization/) on this account. If set, transactions cannot send value of any kind to this account unless the sender of those transactions is the account itself. (Requires the [DepositAuth amendment](https://ripple.com/build/known-amendments/#depositauth)) disableMasterKey | boolean | *Optional* Disallows use of the master key to sign transactions for this account. disallowIncomingXRP | boolean | *Optional* Indicates that client applications should not send XRP to this account. Not enforced by rippled. domain | string | *Optional* The domain that owns this account, as a hexadecimal string representing the ASCII for the domain in lowercase. diff --git a/src/common/constants.ts b/src/common/constants.ts index f7776ee8..f1ed120d 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -4,7 +4,8 @@ import {txFlagIndices} from './txflags' const accountRootFlags = { PasswordSpent: 0x00010000, // password set fee is spent RequireDestTag: 0x00020000, // require a DestinationTag for payments - RequireAuth: 0x00040000, // require a authorization to hold IOUs + RequireAuth: 0x00040000, // require authorization to hold IOUs + DepositAuth: 0x01000000, // require account to auth deposits DisallowXRP: 0x00080000, // disallow sending XRP DisableMaster: 0x00100000, // force regular key NoFreeze: 0x00200000, // permanently disallowed freezing trustlines @@ -16,6 +17,7 @@ const AccountFlags = { passwordSpent: accountRootFlags.PasswordSpent, requireDestinationTag: accountRootFlags.RequireDestTag, requireAuthorization: accountRootFlags.RequireAuth, + depositAuth: accountRootFlags.DepositAuth, disallowIncomingXRP: accountRootFlags.DisallowXRP, disableMasterKey: accountRootFlags.DisableMaster, noFreeze: accountRootFlags.NoFreeze, @@ -26,6 +28,7 @@ const AccountFlags = { const AccountFlagIndices = { requireDestinationTag: txFlagIndices.AccountSet.asfRequireDest, requireAuthorization: txFlagIndices.AccountSet.asfRequireAuth, + depositAuth: txFlagIndices.AccountSet.asfDepositAuth, disallowIncomingXRP: txFlagIndices.AccountSet.asfDisallowXRP, disableMasterKey: txFlagIndices.AccountSet.asfDisableMaster, enableTransactionIDTracking: txFlagIndices.AccountSet.asfAccountTxnID, diff --git a/src/common/schemas/objects/settings.json b/src/common/schemas/objects/settings.json index 046115fd..0b3f3cf6 100644 --- a/src/common/schemas/objects/settings.json +++ b/src/common/schemas/objects/settings.json @@ -5,7 +5,11 @@ "properties": { "defaultRipple": { "type": "boolean", - "description": "Enable [rippling](https://ripple.com/knowledge_center/understanding-the-noripple-flag/) on this account’s trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))" + "description": "Enable [rippling](https://ripple.com/build/understanding-the-noripple-flag/) on this account’s trust lines by default. (New in [rippled 0.27.3](https://github.com/ripple/rippled/releases/tag/0.27.3))" + }, + "depositAuth": { + "type": "boolean", + "description": "Enable [Deposit Authorization](https://ripple.com/build/deposit-authorization/) on this account. If set, transactions cannot send value of any kind to this account unless the sender of those transactions is the account itself. (Requires the [DepositAuth amendment](https://ripple.com/build/known-amendments/#depositauth))" }, "disableMasterKey": { "type": "boolean", diff --git a/src/common/txflags.ts b/src/common/txflags.ts index 0c546264..7f248cb7 100644 --- a/src/common/txflags.ts +++ b/src/common/txflags.ts @@ -55,7 +55,8 @@ const txFlagIndices = { asfAccountTxnID: 5, asfNoFreeze: 6, asfGlobalFreeze: 7, - asfDefaultRipple: 8 + asfDefaultRipple: 8, + asfDepositAuth: 9 } } diff --git a/src/ledger/settings.ts b/src/ledger/settings.ts index 4187769e..ac7602d4 100644 --- a/src/ledger/settings.ts +++ b/src/ledger/settings.ts @@ -11,6 +11,7 @@ type GetSettings = { passwordSpent?: boolean, requireDestinationTag?: boolean, requireAuthorization?: boolean, + depositAuthorization?: boolean, disallowIncomingXRP?: boolean, disableMasterKey?: boolean, enableTransactionIDTracking?: boolean, diff --git a/src/ledger/transaction-types.ts b/src/ledger/transaction-types.ts index cf627161..244638d7 100644 --- a/src/ledger/transaction-types.ts +++ b/src/ledger/transaction-types.ts @@ -42,6 +42,7 @@ type Settings = { passwordSpent?: boolean, requireDestinationTag?: boolean, requireAuthorization?: boolean, + depositAuthorization?: boolean, disallowIncomingXRP?: boolean, disableMasterKey?: boolean, enableTransactionIDTracking?: boolean, diff --git a/test/api-test.js b/test/api-test.js index 84719409..3bd4aa4f 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -233,6 +233,18 @@ describe('RippleAPI', function () { _.partial(checkResult, responses.prepareSettings.flagClear, 'prepare')); }); + it('prepareSettings - set depositAuth flag', function () { + const settings = { depositAuth: true }; + return this.api.prepareSettings(address, settings, instructions).then( + _.partial(checkResult, responses.prepareSettings.flagSetDepositAuth, 'prepare')); + }); + + it('prepareSettings - clear depositAuth flag', function () { + const settings = { depositAuth: false }; + return this.api.prepareSettings(address, settings, instructions).then( + _.partial(checkResult, responses.prepareSettings.flagClearDepositAuth, 'prepare')); + }); + it('prepareSettings - integer field clear', function () { const settings = { transferRate: null }; return this.api.prepareSettings(address, settings, instructions) diff --git a/test/fixtures/responses/index.js b/test/fixtures/responses/index.js index 7a705b1e..c2e66a58 100644 --- a/test/fixtures/responses/index.js +++ b/test/fixtures/responses/index.js @@ -104,6 +104,8 @@ module.exports = { flagsMultisign: require('./prepare-settings-multisign.json'), flagSet: require('./prepare-settings-flag-set.json'), flagClear: require('./prepare-settings-flag-clear.json'), + flagSetDepositAuth: require('./prepare-settings-flag-set-deposit-auth.json'), + flagClearDepositAuth: require('./prepare-settings-flag-clear-deposit-auth.json'), setTransferRate: require('./prepare-settings-set-transfer-rate.json'), fieldClear: require('./prepare-settings-field-clear.json'), noInstructions: require('./prepare-settings-no-instructions.json'), diff --git a/test/fixtures/responses/prepare-settings-flag-clear-deposit-auth.json b/test/fixtures/responses/prepare-settings-flag-clear-deposit-auth.json new file mode 100644 index 00000000..e4b56d83 --- /dev/null +++ b/test/fixtures/responses/prepare-settings-flag-clear-deposit-auth.json @@ -0,0 +1,8 @@ +{ + "txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"ClearFlag\":9,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "0.000012", + "sequence": 23, + "maxLedgerVersion": 8820051 + } +} diff --git a/test/fixtures/responses/prepare-settings-flag-set-deposit-auth.json b/test/fixtures/responses/prepare-settings-flag-set-deposit-auth.json new file mode 100644 index 00000000..a9d4a581 --- /dev/null +++ b/test/fixtures/responses/prepare-settings-flag-set-deposit-auth.json @@ -0,0 +1,8 @@ +{ + "txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"SetFlag\":9,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "0.000012", + "sequence": 23, + "maxLedgerVersion": 8820051 + } +}