moneysurfer 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cli.js +17 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,6 +49,8 @@ A deposit can be withdrawn once the ASP approves it (up to 7 days); until then
|
|
|
49
49
|
A withdrawal goes through 0xbow's relayer, which pays the gas and takes its fee out of
|
|
50
50
|
`<amount>`. With `--self` or `--safe` you submit it instead, and then `<to>` has to be the
|
|
51
51
|
submitter: the pool pays `msg.sender`, and only a relayer's contract splits the payout.
|
|
52
|
+
`--safe` also spends the Safe's own notes; add `--owner ADDR` to have it submit a withdrawal of
|
|
53
|
+
ADDR's notes instead, proposed by any owner or delegate.
|
|
52
54
|
|
|
53
55
|
```sh
|
|
54
56
|
moneysurfer v2 setup
|
package/dist/cli.js
CHANGED
|
@@ -4816,13 +4816,13 @@ async function commands_init(o) {
|
|
|
4816
4816
|
let words = generateMnemonic(english_wordlist, 256);
|
|
4817
4817
|
commands_saveMnemonic(words), v2_commands_out(words);
|
|
4818
4818
|
}
|
|
4819
|
-
async function commands_account(net, c) {
|
|
4819
|
+
async function commands_account(net, c, as) {
|
|
4820
4820
|
let root = function() {
|
|
4821
4821
|
let m = process.env.MONEYSURFER_MNEMONIC ?? (existsSync(commands_MNEMONIC_FILE) ? readFileSync(commands_MNEMONIC_FILE, 'utf8') : void 0);
|
|
4822
4822
|
if (!m) throw new config_UsageError('no seed -- run `moneysurfer v2 init` first, or set MONEYSURFER_MNEMONIC');
|
|
4823
4823
|
if (!validateMnemonic(m.trim(), english_wordlist)) throw new config_UsageError('the seed is not a valid BIP-39 phrase');
|
|
4824
4824
|
return mnemonicToEntropy(m.trim(), english_wordlist);
|
|
4825
|
-
}(), owner = c.safe ?? c.sig.from ?? (await makeSigner(net, config_chainId(), c.sig)).address;
|
|
4825
|
+
}(), owner = as ?? c.safe ?? c.sig.from ?? (await makeSigner(net, config_chainId(), c.sig)).address;
|
|
4826
4826
|
return {
|
|
4827
4827
|
keys: function(rootSecret, revocableKeyIndex = 0n) {
|
|
4828
4828
|
var salt;
|
|
@@ -4923,7 +4923,7 @@ async function register(c) {
|
|
|
4923
4923
|
})
|
|
4924
4924
|
}), !calls.length) return v2_commands_log('already registered; nothing to do');
|
|
4925
4925
|
if (0n !== nullifying && nullifying !== wantNullifying) throw new config_UsageError(`${owner} is registered with a different nullifying key (${hex32(nullifying)}). That is another seed's account -- registering again would orphan its notes`);
|
|
4926
|
-
if (v2_commands_log('this is public:
|
|
4926
|
+
if (v2_commands_log('this is public: anyone can see this address registered with Privacy Pools, but not its deposits or withdrawals'), c.safe) return proposeCalls(net, c, calls, 'the registration');
|
|
4927
4927
|
let signer = await signerFor(net, c, owner);
|
|
4928
4928
|
for (let call of calls){
|
|
4929
4929
|
if (await commands_simulate(net, signer.address, call), c.dryRun) {
|
|
@@ -5183,7 +5183,8 @@ async function commands_withdraw(key, amountArg, to, v, c) {
|
|
|
5183
5183
|
v.self,
|
|
5184
5184
|
c.safe
|
|
5185
5185
|
].filter(Boolean).length > 1) throw new config_UsageError('--relayer, --self and --safe are exclusive');
|
|
5186
|
-
|
|
5186
|
+
if (c.owner && !c.safe) throw new config_UsageError('--owner needs --safe: it names whose notes the Safe spends');
|
|
5187
|
+
let relayed = !(v.self || c.safe), recipient = flags_checksummed(to), net = await commands_connect(), asset = pickAsset(await assets(net), key), { keys, root, owner } = await commands_account(net, c, c.owner);
|
|
5187
5188
|
if (await rpc_read(net, KEYSTORE_ADDR, KEYSTORE.nullifyingKeys, owner) === 0n) throw new config_UsageError(`${owner} is not in the Keystore -- run \`moneysurfer v2 register\` first`);
|
|
5188
5189
|
let signer = relayed ? void 0 : await signerFor(net, c, owner), processor = relayed ? RELAY_ADDR : c.safe ?? signer.address;
|
|
5189
5190
|
if (!relayed && recipient.toLowerCase() !== processor.toLowerCase()) throw new config_UsageError(`a spend pays whoever submits it -- ${processor} -- and the pool will not pay ${recipient}:\n it hands the amount to msg.sender and requires that to be the processooor the proof names.\n Name ${processor} as the recipient, or leave out ${c.safe ? '--safe' : '--self'} and let a relayer\n submit it: its PrivacyPoolRelay is then the processooor and pays the recipient.`);
|
|
@@ -5519,6 +5520,7 @@ async function commands_run(cmd, rest, v, c) {
|
|
|
5519
5520
|
trees: ()=>commands_trees()
|
|
5520
5521
|
};
|
|
5521
5522
|
if (!Object.hasOwn(commands, cmd)) throw new config_UsageError(`unknown v2 command '${cmd}'\n\n${commands_HELP}`);
|
|
5523
|
+
if (c.owner && 'withdraw' !== cmd) throw new config_UsageError('only withdraw takes --owner');
|
|
5522
5524
|
await commands[cmd]();
|
|
5523
5525
|
}
|
|
5524
5526
|
import { availableParallelism, homedir } from "node:os";
|
|
@@ -15565,6 +15567,7 @@ let poly1305 = (macCons = (key)=>new Poly1305(key), getArgs = ()=>[], (macC = (m
|
|
|
15565
15567
|
--relayer URL use this relayer instead of 0xbow's
|
|
15566
15568
|
--self | --safe SAFE submit and pay gas yourself, or have a Safe submit it
|
|
15567
15569
|
<to> has to be the submitter then: the pool pays msg.sender
|
|
15570
|
+
--owner ADDR with --safe: spend ADDR's notes, not the Safe's
|
|
15568
15571
|
v2 ragequit <asset> --id N take a note back publicly, to the owning address
|
|
15569
15572
|
v2 status | trees the deployment, and both trees rebuilt from logs
|
|
15570
15573
|
|
|
@@ -15659,6 +15662,9 @@ try {
|
|
|
15659
15662
|
from: {
|
|
15660
15663
|
type: 'string'
|
|
15661
15664
|
},
|
|
15665
|
+
owner: {
|
|
15666
|
+
type: 'string'
|
|
15667
|
+
},
|
|
15662
15668
|
help: {
|
|
15663
15669
|
type: 'boolean',
|
|
15664
15670
|
short: 'h'
|
|
@@ -15691,7 +15697,12 @@ try {
|
|
|
15691
15697
|
s = explicit ? `${'v2' === protocol ? commands_HELP : HELP}\n\n${SHARED}` : cli_HELP, process.stdout.write(`${s}\n`), process.exit(0);
|
|
15692
15698
|
}
|
|
15693
15699
|
for (let { flag, why } of ({
|
|
15694
|
-
v1: [
|
|
15700
|
+
v1: [
|
|
15701
|
+
{
|
|
15702
|
+
flag: 'owner',
|
|
15703
|
+
why: 'a V1 note has no owner address; the seed alone spends it'
|
|
15704
|
+
}
|
|
15705
|
+
],
|
|
15695
15706
|
v2: []
|
|
15696
15707
|
})[protocol])if (void 0 !== v[flag]) throw new config_UsageError(`${protocol} takes no --${flag}: ${why}`);
|
|
15697
15708
|
rpcOverride = v['rpc-url'];
|
|
@@ -15702,6 +15713,7 @@ try {
|
|
|
15702
15713
|
let common = {
|
|
15703
15714
|
threads,
|
|
15704
15715
|
safe: void 0 === v.safe ? void 0 : flags_checksummed(v.safe),
|
|
15716
|
+
owner: void 0 === v.owner ? void 0 : flags_checksummed(v.owner),
|
|
15705
15717
|
maxFeePercent,
|
|
15706
15718
|
dryRun: v['dry-run'] ?? !1,
|
|
15707
15719
|
sig: {
|