Comparing version 0.1.6 to 0.1.7
@@ -5,5 +5,2 @@ exports.bLight = true; | ||
conf.socksHost = '127.0.0.1'; | ||
conf.socksPort = '9050'; | ||
exports.hub = 'byteball.org/bb-test'; | ||
@@ -10,0 +7,0 @@ exports.deviceName = 'Test device address'; |
@@ -27,3 +27,3 @@ const core = require('../core'); | ||
if (text.match(/To receive free bytes/)) { | ||
core.sendTextMessageToDevice(from_address, 'MDHV3YL2DNBB7PX3GVCC2CRTLKBMKFW3'); | ||
core.sendTextMessageToDevice(from_address, addresses[0]); | ||
console.error('sent', addresses[0]); | ||
@@ -30,0 +30,0 @@ console.error('Awaiting response...'); |
@@ -10,3 +10,2 @@ const core = require('../core'); | ||
let signDevice = core.signDevicePrivateKey(hash); | ||
console.error('SIGN DEVICE', signDevice); | ||
console.error(`verify sign "${signDevice.sign}" device: ${core.verifySign(hash, signDevice.sign, signDevice.pub_b64)}`); | ||
@@ -19,3 +18,2 @@ | ||
let signAddress = core.signWithAddress(addressInfo.account, addressInfo.is_change, addressInfo.address_index, hash); | ||
console.error('SIGN address', signAddress); | ||
console.error(`verify sign "${signAddress.sign}" address: ${core.verifySign(hash, signAddress.sign, signAddress.pub_b64)}`); | ||
@@ -22,0 +20,0 @@ |
@@ -153,25 +153,4 @@ const Channel = require('./Channel'); | ||
} | ||
getNewChannel(objInfo) { | ||
const device = require('byteballcore/device'); | ||
let params = { | ||
walletId: this.walletId, | ||
myDeviceAddress: device.getMyDeviceAddress(), | ||
peerDeviceAddress: objInfo.peerDeviceAddress, | ||
peerAddress: objInfo.myAddress, | ||
myAmount: objInfo.peerAmount, | ||
peerAmount: objInfo.myAmount, | ||
age: objInfo.age, | ||
id: objInfo.id, | ||
peerUnilateralAddress: objInfo.myUnilateralAddress, | ||
peerDestinationAddress: objInfo.myDestinationAddress | ||
}; | ||
if (this.timeout) { | ||
params.timeout = this.timeout; | ||
} | ||
return new Channel(params); | ||
} | ||
} | ||
module.exports = AutoReNewChannels; | ||
module.exports = AutoReNewChannels; |
@@ -118,5 +118,13 @@ const crypto = require('crypto'); | ||
await this.updateInDb(); | ||
} else if (objMessage.step === 'channelAddress') { | ||
let check = ChannelUtils.checkSharedAddress(this, objMessage.channelAddress, objMessage.arrDefinition); | ||
} else if (objMessage.step === 'addressesAndContract') { | ||
let check = ChannelUtils.check1Contract(this, objMessage.contract.shared_address, objMessage.contract.arrDefinition); | ||
if (!check.status) { | ||
console.error(new Error('1Contract incorrect. code:' + check.code)); | ||
return this.reject(); | ||
} | ||
await libAddress.addIfNotExistRemoteAddresses(objMessage.arrAddressesRows, this.peerDeviceAddress); | ||
await this.saveHash(objMessage.contract.shared_address, objMessage.contract.arrDefinition); | ||
this.objPeerContract = objMessage.contract; | ||
let check2 = ChannelUtils.checkSharedAddress(this, objMessage.channelAddress, objMessage.arrDefinition); | ||
if (!check2.status) { | ||
console.error(new Error('SharedAddress incorrect. code:' + check.code)); | ||
@@ -139,30 +147,12 @@ return this.reject(); | ||
let arrAddressesRows = await libAddress.getAddressesFromDb([this.myAddress, this.myUnilateralAddress, this.myDestinationAddress]); | ||
core.sendTechMessageToDevice(this.peerDeviceAddress, { | ||
step: 'getInputsAndAddresses', | ||
contract: this.objMyContract, | ||
id: this.id, | ||
arrAddressesRows | ||
}); | ||
this.step = 'await_getInputsAndAddresses'; | ||
await this.updateInDb(); | ||
} else if (objMessage.step === 'getInputsAndAddresses' && this.step === 'await_get1Contract_peer') { | ||
let check = ChannelUtils.check1Contract(this, objMessage.contract.shared_address, objMessage.contract.arrDefinition); | ||
if (!check.status) { | ||
console.error(new Error('1Contract incorrect. code:' + check.code)); | ||
return this.reject(); | ||
} | ||
await libAddress.addIfNotExistRemoteAddresses(objMessage.arrAddressesRows, this.peerDeviceAddress); | ||
await this.saveHash(objMessage.contract.shared_address, objMessage.contract.arrDefinition); | ||
this.objPeerContract = objMessage.contract; | ||
await this.sendInputsAndAddresses(); | ||
await this.updateInDb(); | ||
} else if (objMessage.step === 'inputsAndAddresses' && this.step === 'await_getInputsAndAddresses') { | ||
await libAddress.addIfNotExistRemoteAddresses(objMessage.arrAddressesRows, this.peerDeviceAddress); | ||
let objChannelContract = await this.createChannelContract(); | ||
this.channelAddress = objChannelContract.shared_address; | ||
core.sendTechMessageToDevice(this.peerDeviceAddress, { | ||
step: 'channelAddress', | ||
step: 'addressesAndContract', | ||
channelAddress: this.channelAddress, | ||
arrDefinition: objChannelContract.arrDefinition, | ||
id: this.id | ||
id: this.id, | ||
contract: this.objMyContract, | ||
arrAddressesRows | ||
}); | ||
@@ -493,2 +483,3 @@ let objJoint = await this.createChannel(objMessage); | ||
this.objMyContract = await this.create1Contract(this.myAmount, this.peerAmount); | ||
let inpAndAddr = await this.getInputsAndAddresses(); | ||
core.sendTechMessageToDevice(this.peerDeviceAddress, { | ||
@@ -500,5 +491,10 @@ step: '1Contract', | ||
myUnilateralAddress: this.myUnilateralAddress, | ||
myDestinationAddress: this.myDestinationAddress | ||
myDestinationAddress: this.myDestinationAddress, | ||
inputs: inpAndAddr.inputs, | ||
total_input: inpAndAddr.total_input, | ||
myPayingAddresses: inpAndAddr.myPayingAddresses, | ||
arrAddressesRows: inpAndAddr.arrAddressesRows, | ||
newAddress: inpAndAddr.newAddress | ||
}); | ||
this.step = 'await_get1Contract_peer'; | ||
this.step = 'await_createChannel'; | ||
await this.updateInDb(); | ||
@@ -584,3 +580,3 @@ } | ||
async sendInputsAndAddresses() { | ||
async getInputsAndAddresses() { | ||
this.addresses = await libAddress.getNonEmptyAddressesInWallet(this.walletId); | ||
@@ -592,4 +588,3 @@ let objPick = await Channel.pickDivisibleCoinsForAmount(db, {asset: null}, this.addresses, this.myAmount + (constants.FEES_FOR_CHANNEL_OPERATIONS * 2) | ||
let arrAddressesRows = await libAddress.getAddressesFromDb(myPayingAddresses.concat([this.myAddress, this.myUnilateralAddress, this.myDestinationAddress])); | ||
core.sendTechMessageToDevice(this.peerDeviceAddress, { | ||
step: 'inputsAndAddresses', | ||
return { | ||
inputs: objPick.arrInputs, | ||
@@ -599,15 +594,4 @@ total_input: objPick.total_input, | ||
arrAddressesRows, | ||
id: this.id, | ||
newAddress: await core.createNewAddress(this.walletId) | ||
}); | ||
this.unlockPick = objPick.unlock; | ||
setTimeout(() => { | ||
if (this.unlockPick) { | ||
this.unlockPick(); | ||
} | ||
}, MAX_UNLOCK_TIMEOUT); | ||
this.step = 'await_createChannel'; | ||
return true; | ||
}; | ||
} | ||
@@ -614,0 +598,0 @@ |
{ | ||
"name": "biot-core", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "core.js", |
@@ -24,8 +24,5 @@ # biot-core | ||
1) **A:** await_get1Contract_initiator | ||
2) **B:** get1Contract | ||
3) **B:** await_get1Contract_peer | ||
4) **A:** await_getInputsAndAddresses | ||
5) **B:** await_createChannel | ||
6) **A:** waiting_transfers | ||
7) **B:** waiting_transfers | ||
2) **B:** await_createChannel | ||
3) **A:** waiting_transfers | ||
4) **B:** waiting_transfers | ||
@@ -61,4 +58,9 @@ | ||
4) **B:** inputsAndAddresses | ||
5) **A:** channelAddress | ||
5) **A:** addressesAndContract | ||
#### Opening of channel | ||
1) **A:** get1Contract | ||
2) **B:** 1Contract | ||
3) **A:** addressesAndContract | ||
#### Transfer | ||
@@ -65,0 +67,0 @@ 1) **A:** transfer_start |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123956
3278
74