Skip to content

Commit

Permalink
wallet: add icannlockup support behind a flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Jun 1, 2023
1 parent 3fa91f1 commit d19547f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/wallet/node.js
Expand Up @@ -51,7 +51,8 @@ class WalletNode extends Node {
cacheSize: this.config.mb('cache-size'),
wipeNoReally: this.config.bool('wipe-no-really'),
spv: this.config.bool('spv'),
walletMigrate: this.config.uint('migrate')
walletMigrate: this.config.uint('migrate'),
icannlockup: this.config.bool('icannlockup', false)
});

this.rpc = new RPC(this);
Expand Down
3 changes: 2 additions & 1 deletion lib/wallet/plugin.js
Expand Up @@ -56,7 +56,8 @@ class Plugin extends EventEmitter {
cacheSize: this.config.mb('cache-size'),
wipeNoReally: this.config.bool('wipe-no-really'),
spv: node.spv,
walletMigrate: this.config.uint('migrate')
walletMigrate: this.config.uint('migrate'),
icannlockup: this.config.bool('icannlockup', false)
});

this.rpc = new RPC(this);
Expand Down
4 changes: 4 additions & 0 deletions lib/wallet/wallet.js
Expand Up @@ -1643,11 +1643,15 @@ class Wallet extends EventEmitter {
const nameHash = rules.hashName(rawName);
const height = this.wdb.height + 1;
const network = this.network;
const {icannlockup} = this.wdb.options;

// TODO: Handle expired behavior.
if (rules.isReserved(nameHash, height, network))
throw new Error(`Name is reserved: ${name}.`);

if (icannlockup && rules.isLockedUp(nameHash, height, network))
throw new Error(`Name is locked up: ${name}.`);

if (!rules.hasRollout(nameHash, height, network))
throw new Error(`Name not yet available: ${name}.`);

Expand Down
6 changes: 6 additions & 0 deletions lib/wallet/walletdb.js
Expand Up @@ -2468,6 +2468,7 @@ class WalletOptions {
this.spv = false;
this.wipeNoReally = false;
this.walletMigrate = -1;
this.icannlockup = false;

if (options)
this.fromOptions(options);
Expand Down Expand Up @@ -2550,6 +2551,11 @@ class WalletOptions {
this.walletMigrate = options.walletMigrate;
}

if (options.icannlockup != null) {
assert(typeof options.icannlockup === 'boolean');
this.icannlockup = options.icannlockup;
}

return this;
}

Expand Down

0 comments on commit d19547f

Please sign in to comment.