Conversation
A provisional tag is currently used, the correct tag creation procedure will be implemented later.
Done to check if Travis CI sees the commented out lines
src/trust_is_risk.js
Outdated
|
|
||
| class TrustIsRisk { | ||
| node : bcoin$FullNode | ||
| node : (bcoin$FullNode | bcoin$SPVNode) |
src/trust_is_risk.js
Outdated
|
|
||
| class TrustIsRisk { | ||
| node : bcoin$FullNode | ||
| node : (bcoin$FullNode | bcoin$SPVNode) |
There was a problem hiding this comment.
Check if you can type this with the superclass
src/trust_is_risk.js
Outdated
| // secp256k1 curve: y^2 = x^3 + 7 | ||
| 0x05, 0x5d, 0x5f, 0x28, 0x5e, 0xd7, 0x9d, 0x0c, | ||
| 0x6f, 0x61, 0xc3, 0x0e, 0xfc, 0x9d, 0x21, 0x91, | ||
| 0x65, 0x82, 0x80, 0x59, 0xa6, 0x01, 0x25, 0x0c, // 32 bytes with the y coordinate |
There was a problem hiding this comment.
Keep lines short, move comments above the lines they're describing
src/trust_is_risk.js
Outdated
| 0x54, 0x72, 0x75, 0x73, 0x74, 0x20, 0x69, 0x73, | ||
| 0x20, 0x52, 0x69, 0x73, 0x6b, 0x00, 0x00, 0x00, // only x is given in short version | ||
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]; |
There was a problem hiding this comment.
DRY, compress using above constants
There was a problem hiding this comment.
Removed compressed version entirely
src/trust_is_risk.js
Outdated
| this.fakePubKeyArray = [0x04, // constant 0x04 prefix | ||
| 0x54, 0x72, 0x75, 0x73, 0x74, 0x20, 0x69, 0x73, | ||
| 0x20, 0x52, 0x69, 0x73, 0x6b, 0x00, 0x00, 0x00, // 32 bytes with the x coordinate | ||
| 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // containing ASCII "Trust is Risk" |
There was a problem hiding this comment.
Deduce this from the string 'Trust is Risk' instead of typing it out fully; at least the x part
There was a problem hiding this comment.
Removed compressed versions completely
src/trust_is_risk.js
Outdated
| this.tag = Buffer.from(this.fakeKeyRing.getAddress("base58")); | ||
|
|
||
|
|
||
| this.compressedFakePubKeyArray = [0x02, // 0x02 prefix for even y values |
There was a problem hiding this comment.
Remove compressed vars
src/trust_is_risk.js
Outdated
| compressedTag : Buffer | ||
|
|
||
| constructor(node : (bcoin$FullNode | bcoin$SPVNode)) { | ||
| this.fakePubKeyArray = [0x04, // constant 0x04 prefix |
There was a problem hiding this comment.
Indent comment correctly
src/trust_is_risk.js
Outdated
| compressedTag : Buffer | ||
|
|
||
| constructor(node : (bcoin$FullNode | bcoin$SPVNode)) { | ||
| this.fakePubKeyArray = [0x04, // constant 0x04 prefix |
There was a problem hiding this comment.
Put the constants out of the class. Use corresponding --harmony flags in the package.json file
There was a problem hiding this comment.
@dionyziz There's a million flags, I went one time through them all but they seem to do something else entirely. I read a bit about ESnext and I understood that's a completely separate transpiler (?) that we're currently not using. Can you give me a pointer?
There was a problem hiding this comment.
Managed to do it without new flags. Check if the result is OK.
test/helpers.js
Outdated
|
|
||
| getOneOfTwoMultisigOutput: (originPubKey, destPubKey, value) => { | ||
| getOneOfThreeMultisigOutput: (originPubKey, destPubKey, value) => { | ||
| tag = (new TrustIsRisk.TrustIsRisk(new bcoin.fullnode({}))).fakePubKey; |
There was a problem hiding this comment.
use the const that is outside the TrustIsRisk class
test/helpers.js
Outdated
|
|
||
| getOneOfTwoMultisigOutput: (originPubKey, destPubKey, value) => { | ||
| getOneOfThreeMultisigOutput: (originPubKey, destPubKey, value) => { | ||
| tag = (new TrustIsRisk.TrustIsRisk(new bcoin.fullnode({}))).fakePubKey; |
test/helpers.js
Outdated
| tag = (new TrustIsRisk.TrustIsRisk(new bcoin.fullnode({}))).fakePubKey; | ||
| return new bcoin.primitives.Output({ | ||
| script: bcoin.script.fromMultisig(1, 2, [originPubKey, destPubKey]), | ||
| script: bcoin.script.fromMultisig(1, 3, [originPubKey, destPubKey, tag]), |
| @@ -0,0 +1,27 @@ | |||
| # Thanks to http://code.activestate.com/recipes/577821-integer-square-root-function/ for isqrt() | |||
There was a problem hiding this comment.
move to new directory etc
test/trust_is_risk.js
Outdated
| }); | ||
|
|
||
| it("is a valid bitcoin address", () => { | ||
| assert(bcoin.primitives.Address.fromBase58(tir.tag.toString("ascii"))); |
There was a problem hiding this comment.
bcoin.primitives.Address.fromBase58(tir.tag.toString("ascii")).should.be.ok
test/trust_is_risk.js
Outdated
| var sinon = require("sinon"); | ||
| var should = require("should"); | ||
| var fixtures = require("./fixtures"); | ||
| var assert = require("assert"); |
No description provided.