Skip to content
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

Add Bitcoin RPC provider #65

Merged
merged 8 commits into from Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion examples/node/bitcoin/ledger.js
Expand Up @@ -5,5 +5,11 @@ const bitcoin = new Client()
bitcoin.addProvider(new BitcoinLedgerProvider())

;(async () => {
console.log(await bitcoin.signMessage('hello world'))
try {
const [ address ] = await bitcoin.getAddresses(0, 1)
console.log(address)
console.log(await bitcoin.signMessage('hello world', address))
} catch (e) {
console.log(e)
}
})()
8 changes: 7 additions & 1 deletion examples/node/ethereum/ledger.js
Expand Up @@ -5,5 +5,11 @@ const ethereum = new Client()
ethereum.addProvider(new EthereumLedgerProvider())

;(async () => {
console.log(await ethereum.signMessage('hello world'))
try {
const [ address ] = await ethereum.getAddresses(0, 1)
console.log(address)
console.log(await ethereum.signMessage('hello world', address))
} catch (e) {
console.log(e)
}
})()
28 changes: 0 additions & 28 deletions examples/node/ethereum/multiple-providers.js

This file was deleted.

5 changes: 5 additions & 0 deletions examples/node/ledger.js
@@ -0,0 +1,5 @@
const { LedgerProvider } = require('../../')

;(async () => {
console.log(await LedgerProvider.isSupported())
})()
32 changes: 32 additions & 0 deletions examples/node/multiple-providers.js
@@ -0,0 +1,32 @@
const { Client, Provider } = require('../../')

class X extends Provider {
signMessage (message, from) {
return message + ' X'
}
}

class Y extends Provider {
signMessage (message, from) {
return this.getMethod('signMessage')(message, from) + ' Y'
}
}

class Z extends Provider {
signMessage (message, from) {
return this.getMethod('signMessage')(message, from) + ' Z'
}
}

const client = new Client()
client.addProvider(new X())
.addProvider(new Y())
.addProvider(new Z())

;(async () => {
try {
console.log(await client.signMessage('hello world'))
} catch (e) {
console.error(e)
}
})()
9 changes: 5 additions & 4 deletions examples/swap/swap-e2e.html
Expand Up @@ -88,13 +88,14 @@ <h3>Claim swap:</h3>
}

function initiateSwap (client, prefix) {
var swapBytecode = client.generateSwap(
client.createSwapScript(
$(`#${prefix}RecipientAddress`).val(),
$(`#${prefix}RefundAddress`).val(),
$(`#${prefix}SecretHash`).val(),
parseInt($(`#${prefix}Expiration`).val())
)
$(`#${prefix}SwapBytecode`).text(swapBytecode)
).then(result => {
$(`#${prefix}SwapBytecode`).text(result)
})

client.initiateSwap(
parseInt($(`#${prefix}FundValue`).val()),
Expand Down Expand Up @@ -129,4 +130,4 @@ <h3>Claim swap:</h3>
</script>
</body>

</html>
</html>
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -38,6 +38,7 @@
"build:dev:node": "webpack --config ./webpack/webpack.node.config.js",
"build:dev:browser": "webpack --config ./webpack/webpack.browser.config.js",
"build:dev": "webpack --config ./webpack/webpack.config.js",
"watch": "WEBPACK_WATCH=true webpack --config ./webpack/webpack.config.js",
"build:node": "cross-env NODE_ENV=production BABEL_ENV=production npm run build:dev:node",
"build:browser": "cross-env NODE_ENV=production BABEL_ENV=production npm run build:dev:browser",
"build": "cross-env NODE_ENV=production BABEL_ENV=production npm run build:dev",
Expand Down
15 changes: 15 additions & 0 deletions src/Address.js
@@ -0,0 +1,15 @@
export default class Address {
constructor (address, derivationPath, index = false) {
this.address = address
this.derivationPath = derivationPath
this.index = index
}

toString () {
return this.address
}

toLocaleString () {
return this.address
}
}