diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-04-27 03:09:29 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-04-27 03:09:29 +0200 |
commit | 82b5754e157a1a3b22afe48c8366c76525eb91e3 (patch) | |
tree | c50afc6bac7535481a73ebc29049e393444f7edc /src/cryptoWorker.ts | |
parent | 68e44e0e80635b00333ef2fcbb0ad937581344ba (diff) | |
download | wallet-core-82b5754e157a1a3b22afe48c8366c76525eb91e3.tar.xz |
download, store and check signatures for wire fees
Diffstat (limited to 'src/cryptoWorker.ts')
-rw-r--r-- | src/cryptoWorker.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/cryptoWorker.ts b/src/cryptoWorker.ts index cb7bee40b..4275d659b 100644 --- a/src/cryptoWorker.ts +++ b/src/cryptoWorker.ts @@ -30,7 +30,7 @@ import create = chrome.alarms.create; import {OfferRecord} from "./wallet"; import {CoinWithDenom} from "./wallet"; import {CoinPaySig, CoinRecord} from "./types"; -import {DenominationRecord, Amounts} from "./types"; +import {DenominationRecord, Amounts, WireFee} from "./types"; import {Amount} from "./emscriptif"; import {HashContext} from "./emscriptif"; import {RefreshMeltCoinAffirmationPS} from "./emscriptif"; @@ -110,6 +110,25 @@ namespace RpcFunctions { nativePub); } + export function isValidWireFee(type: string, wf: WireFee, masterPub: string): boolean { + let p = new native.MasterWireFeePS({ + h_wire_method: native.ByteArray.fromStringWithNull(type).hash(), + start_date: native.AbsoluteTimeNbo.fromStamp(wf.startStamp), + end_date: native.AbsoluteTimeNbo.fromStamp(wf.endStamp), + wire_fee: (new native.Amount(wf.wireFee)).toNbo(), + closing_fee: (new native.Amount(wf.closingFee)).toNbo(), + }); + + let nativeSig = new native.EddsaSignature(); + nativeSig.loadCrock(wf.sig); + let nativePub = native.EddsaPublicKey.fromCrock(masterPub); + + return native.eddsaVerify(native.SignaturePurpose.MASTER_WIRE_FEES, + p.toPurpose(), + nativeSig, + nativePub); + } + export function isValidDenom(denom: DenominationRecord, masterPub: string): boolean { |