-
Notifications
You must be signed in to change notification settings - Fork 1k
[Add] Multi-Sig Support in Wallets
#4213
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
Changes from 7 commits
77c1719
c6c5df1
c82731f
7899613
ff491dd
42fccae
3394cc6
18c349a
294d9a9
9a13abe
0213299
c1faf3a
96dbcb1
58f8059
bae6d8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,6 +136,26 @@ protected Wallet(string path, ProtocolSettings settings) | |
| Path = path; | ||
| } | ||
|
|
||
| public WalletAccount CreateMultiSigAccount(params ECPoint[] publicKeys) => | ||
| CreateMultiSigAccount(publicKeys.Length, publicKeys); | ||
cschuchardt88 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| public WalletAccount CreateMultiSigAccount(int m, params ECPoint[] publicKeys) | ||
| { | ||
| ArgumentOutOfRangeException.ThrowIfEqual(publicKeys.Length, 0, nameof(publicKeys)); | ||
| ArgumentOutOfRangeException.ThrowIfGreaterThan(m, publicKeys.Length, nameof(publicKeys)); | ||
| ArgumentOutOfRangeException.ThrowIfLessThan(m, 1, nameof(m)); | ||
| ArgumentOutOfRangeException.ThrowIfGreaterThan(m, 1024, nameof(m)); | ||
|
|
||
| var contract = Contract.CreateMultiSigContract(m, publicKeys); | ||
| var account = GetAccounts().FirstOrDefault( | ||
|
||
| f => | ||
| f.HasKey && | ||
| f.Lock == false && | ||
| publicKeys.Contains(f.GetKey().PublicKey)); | ||
|
|
||
| return CreateAccount(contract, account?.GetKey()); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates a standard account for the wallet. | ||
| /// </summary> | ||
|
|
@@ -237,6 +257,12 @@ public WalletAccount CreateAccount(Contract contract, byte[] privateKey) | |
| return result; | ||
| } | ||
|
|
||
| public IEnumerable<WalletAccount> GetMultiSigAccounts() => | ||
| GetAccounts() | ||
| .Where(static w => | ||
| w.Lock == false && | ||
| IsMultiSigContract(w.Contract.Script)); | ||
|
|
||
| /// <summary> | ||
| /// Gets the account with the specified public key. | ||
| /// </summary> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.