-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbackground.js
More file actions
53 lines (38 loc) · 1.21 KB
/
Copy pathbackground.js
File metadata and controls
53 lines (38 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// TODO: Wallet should be global?
var Wallet = SpareCoins.Wallet( SpareCoins.ChromeStorage )
var pushTransaction = function( txSerialized, txHash, txValue, callback ) {
BitcoinNodeAPI.pushTx( txSerialized, txHash, function( err, data ) {
if ( err ) {
console.log( txSerialized )
console.log( txHash )
console.log( err )
throw new Error( "Transaction Failed" )
}
if ( data ) {
beep()
// Backup Wallet if high value
var target = BigInteger.valueOf( 10000000 )
if ( ( txValue ).compareTo( target ) > 0 ) {
backupPrivateKeys()
}
callback()
}
} );
}
var beep = function() {
var file = "beep.wav"
return ( new Audio( file ) ).play()
}
var backupPrivateKeys = function() {
Wallet.loadData( function() {
var timestamp = ( new Date() ).getTime()
var addresses = Wallet.getAddresses()
var encryptedKeysURL = "data:text/csv;charset=utf-8,"
encryptedKeysURL += escape( "Encrypted Privated Keys (AES)" + "\n" )
encryptedKeysURL += escape( "Use a SHA256 digest of your password as the encryption key" + "\n" )
for ( var i = 0; i < addresses.length; i++ ) {
encryptedKeysURL += escape( addresses[ i ].getfCryptPrivateKey() + "\n" )
}
window.open( encryptedKeysURL )
} )
}