- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的设置:
在 Mongoose 模块的帮助下,我们处理所有 Mongo 数据库操作。对于每个新用户,都会生成一个钱包并将其存储在 Mongo 集合中。
方法:
如果我们使用User.find({}, function(err, docs) {
。我们可以获取每个用户对象。
User.find({}, function(err, docs) {
if (err) {console.log('Could not find Wallets in DB');} else {
docs.forEach(function(address) {
console.log(address);
});
}
});
// console.log(address); <== Result:
{ tokens: [],
profile: { gender: '', location: '', website: '', picture: '' },
__v: 0,
balance: 0,
playerWallet: '2N3qPHp7bNaL4hiztrzZCzCywryKUzb5aLE',
password: '$2a$10$JRs/hyiStyhcZzHBwFnhmulKX0vTqlNMTGdxJjDdCSD0Bufe7K6wC',
email: '111111111111111111111@11111111111111111.com',
username: '111111111111111111111',
createdAt: Mon May 02 2016 01:38:11 GMT+0300 (EEST),
updatedAt: Mon May 02 2016 01:38:17 GMT+0300 (EEST),
_id: 57268553ea2d6bb50c9d4069
}
2N3qPHp7bNaL4hiztrzZCzCywryKUzb5aLE }
{ tokens: [],
profile: { gender: '', location: '', website: '', picture: '' },
__v: 0,
balance: 0,
playerWallet: '2N2oG4nBJZU19Aks3MLvHqDKMXePmHhbEjC',
password: '$2a$10$cCo5gQgqcRpQW9Dl/Q.48uJEQCaOpJOLY8LVpQxoQFZ6nUqQD8lEC',
email: '2222222222222222222222222@222222222222222222.com',
username: '2222222222222222222222222',
createdAt: Mon May 02 2016 01:38:38 GMT+0300 (EEST),
updatedAt: Mon May 02 2016 01:38:44 GMT+0300 (EEST),
_id: 5726856eea2d6bb50c9d406a
}
2N2oG4nBJZU19Aks3MLvHqDKMXePmHhbEjC
{ tokens: [],
profile: { gender: '', location: '', website: '', picture: '' },
__v: 0,
balance: 0,
playerWallet: '2My1FGBG6erNXfzeGXg5DXnLk2PWxhpk9SL',
password: '$2a$10$tL96HqPIAi6q8XnI3z4Bc.dX88fTYQXsTt.UFWJQn4k6ZdDFOZLe2',
email: '33333333333333333333333@33333333333333333333333.com',
username: '33333333333333333333333',
createdAt: Mon May 02 2016 01:39:03 GMT+0300 (EEST),
updatedAt: Mon May 02 2016 01:39:09 GMT+0300 (EEST),
_id: 57268587ea2d6bb50c9d406b
}
问题就在这里:
因为我使用 for 循环来迭代所有钱包地址,所以我收到 3 个不同的调用,并且每次总是获取一个对象。我从来没有将超过 1 个 User 对象存储到我的 .JSON 文件中。
var _24HourGame = ".24HourGame.json"; // Save Path
var user = 'Super@User.com';
var loginPassword = 'SuperSecretPassword';
var otp = '0000000';
var bitgo = new BitGoJS.BitGo();
var listWallets = function() {
User.find({}, function(err, docs) {
if (err) {console.log('Could not find Wallets in DB');} else {
docs.forEach(function(address) {
console.log(address);
var allWallets = [];
allWallets.push(address.playerWallet);
console.log(allWallets);
// ALL ADDRESSEs EACH IN ITS OWN ARRAY
//[ '2N3qPHp7bNaL4hiztrzZCzCywryKUzb5aLE' ]
//[ '2N2oG4nBJZU19Aks3MLvHqDKMXePmHhbEjC' ]
//[ '2My1FGBG6erNXfzeGXg5DXnLk2PWxhpk9SL' ]
// Don't know how to use a better method that calls back recursively and sums all 3 obj received into an array....
for( var iteration in allWallets){
console.log(allWallets[iteration]);
// '2N3qPHp7bNaL4hiztrzZCzCywryKUzb5aLE'
// '2N2oG4nBJZU19Aks3MLvHqDKMXePmHhbEjC'
// '2My1FGBG6erNXfzeGXg5DXnLk2PWxhpk9SL'
// How to call a Recursive Callbacks or a Promise for bitgo.wallets().gest({}) while iterating multiple address?
bitgo.wallets().get({ "id": allWallets[iteration] }, function callback(err, wallet) {
if (err) { throw err; }
console.log( address._id + ' ' + address.playerWallet + ' ' + 'BlockChain_Balance: ' + wallet.balance() / 1e8.toFixed(4) + ' DB_Balance: ' );
jsonfile.writeFileSync(_24HourGame, wallet, {spaces: 3});
});
}
});
}
});
};
// Authenticate first
bitgo.authenticate({ username: user, password: loginPassword, otp: otp }, function(err, result) {
if (err) { console.dir(err); throw new Error("Could not authenticate!"); }
console.log("Unlocking account.." );
bitgo.unlock({ otp: otp }, function(err) {
if (err) { console.dir(err); throw new Error("Could not unlock!"); }
listWallets();
});
});
当我将结果保存到 JSON 时,我一次只能获取一个对象:
{
"_id": "5726858f42929c5c066825b6cc7f9d96",
"id": "2My1FGBG6erNXfzeGXg5DXnLk2PWxhpk9SL",
"label": "123labeling",
"isActive": true,
"type": "safehd",
"freeze": {},
"adminCount": 1,
"disableTransactionNotifications": false,
"private": {
"keychains": [
{
"xpub": "xpub661MyMwAqRbcG8zA12U9YnJU3fSxoCq857uMcFon6ViZdYMSeXbeVUGtGkBCasmE3SGdJVRr4ui1V8TzsmM7K6eKikSi9gZQiJXoVumGTnU",
"path": "/0/0",
"params": {
"pubKey": "031ec65814f7e46e274a78671f6ed2b945c386e378160b19613ce8ba555e793635",
"chainCode": "a046f6f6ea9fd06974b333e87a483c9c3cbdeb41c0e56c8f21a6954f9f95e387",
"depth": 0,
"index": 0,
"parentFingerprint": 0
}
},
{
"xpub": "xpub6GiRC55CRvMEnS2CtwqrMNKDnpsogbX1tukjM2xWyW1PttVLSEVgDiJq7bWh6esAQWeQ9oGNR56RHqwzKLCzzneM6DGq91v8sA9DAJbUbtm",
"path": "/0/0",
"params": {
"pubKey": "027f30812a8f33ffeb44515d0fe9cc99041c2369f407ecc537d492d34da48c29d2",
"chainCode": "4f493067187019f78a773e3e559c699b98c0e82a53cbf76cf9ba5db8103062a0",
"depth": 5,
"index": 58402,
"parentFingerprint": 2966462100
}
},
{
"xpub": "xpub661MyMwAqRbcF6cBQfmTER34dwShTVu6x2h24nxhHxMX3jAHCP9DJYuLcHABvaMeaBcSMdcte8mhAMnCcBCypK5iGe6H33aUH8JWbstSKP9",
"path": "/0/0",
"params": {
"pubKey": "02ec33597217f00f1ad5689b0abbfd01d850c921d4560d1333f52f9f70eea2aafd",
"chainCode": "37b746ccdf38587d6a943f8007ef9e3012f52c73079f53c094f446cd43f9bb4f",
"depth": 0,
"index": 0,
"parentFingerprint": 0
}
}
]
},
"canSendInstant": true,
"permissions": "admin,spend,view",
"admin": {
"users": [
{
"user": "56f9e3b2cd8f2e5906530948fe1af2d2",
"permissions": "admin,spend,view"
}
]
},
"tags": [],
"approvalsRequired": 1,
"spendingAccount": true,
"pendingApprovals": [],
"balance": 30000000,
"instantBalance": 0,
"spendableConfirmedBalance": 0,
"confirmedBalance": 0,
"spendableBalance": 0,
"sent": 0,
"received": 30000000,
"unconfirmedSends": 0,
"unconfirmedReceives": 30000000
}
我想将所有对象汇总到一个对象数组中...:
[
{
"_id": "5726857642929c5c066825819a872925",
"id": "2N2oG4nBJZU19Aks3MLvHqDKMXePmHhbEjC",
"label": "123labeling",
"isActive": true,
"type": "safehd",
"freeze": {},
"adminCount": 1,
"disableTransactionNotifications": false,
"private": {
"keychains": [
{
"xpub": "xpub661MyMwAqRbcH2AHKRsNyEv4euymBzY8P52NzeodZBBvG8zPtpLeEJmjD8xevZRrDLCyCr4TjmavB9TuAw69bDH3TkKNPyEQ2UBVrGg8uVq",
"path": "/0/0",
"params": {
"pubKey": "038c20add130bf5d79fc1debc658e8866f5c69962efc15350941d18cc3b88c025f",
"chainCode": "f8e61f519f8e5363b24fe19912a25c90395a9189f59517d5c888c2b2eaefe4ba",
"depth": 0,
"index": 0,
"parentFingerprint": 0
}
},
{
"xpub": "xpub6GiRC55CRvMEkcMvj2xtGSMhQzAys7EMV4gvqporNz5kSkzuqt3x25cnpvYWyR24y38WYij7eLr3xSQsBo7TBHWR27b5QZTrj5sVq5MMBVa",
"path": "/0/0",
"params": {
"pubKey": "037e26f5594705a05a49e63dbd7eb98e0fb56d0f26b584c8e4fcdb15efd0239d62",
"chainCode": "984f19d3ae866a97a1b3a0bad1abf2a9aa77dbf50465180dee0cf8a8b73089c8",
"depth": 5,
"index": 58401,
"parentFingerprint": 2966462100
}
},
{
"xpub": "xpub661MyMwAqRbcGdVpPbFpvi37Ziteqj4JY3uEoV6XijMAk62Pgs2jK3bRPPVjKg4AtwbZ6xiMMHD56oHCdGQwqtWNZgwSWefw9edex9aJ9KC",
"path": "/0/0",
"params": {
"pubKey": "03b323e0b6ebb0cbb845be13c5a090c4648de18c090382e899e66c389c0f6451fc",
"chainCode": "d1a6e364a4b44764190148e725a8c584583743d31df2d06439b70016e19799b5",
"depth": 0,
"index": 0,
"parentFingerprint": 0
}
}
]
},
"canSendInstant": true,
"permissions": "admin,spend,view",
"admin": {
"users": [
{
"user": "56f9e3b2cd8f2e5906530948fe1af2d2",
"permissions": "admin,spend,view"
}
]
},
"tags": [],
"approvalsRequired": 1,
"spendingAccount": true,
"pendingApprovals": [],
"balance": 533000000,
"instantBalance": 0,
"spendableConfirmedBalance": 0,
"confirmedBalance": 0,
"spendableBalance": 0,
"sent": 0,
"received": 533000000,
"unconfirmedSends": 0,
"unconfirmedReceives": 533000000
},
{
"_id": "5726858f42929c5c066825b6cc7f9d96",
"id": "2My1FGBG6erNXfzeGXg5DXnLk2PWxhpk9SL",
"label": "123labeling",
"isActive": true,
"type": "safehd",
"freeze": {},
"adminCount": 1,
"disableTransactionNotifications": false,
"private": {
"keychains": [
{
"xpub": "xpub661MyMwAqRbcG8zA12U9YnJU3fSxoCq857uMcFon6ViZdYMSeXbeVUGtGkBCasmE3SGdJVRr4ui1V8TzsmM7K6eKikSi9gZQiJXoVumGTnU",
"path": "/0/0",
"params": {
"pubKey": "031ec65814f7e46e274a78671f6ed2b945c386e378160b19613ce8ba555e793635",
"chainCode": "a046f6f6ea9fd06974b333e87a483c9c3cbdeb41c0e56c8f21a6954f9f95e387",
"depth": 0,
"index": 0,
"parentFingerprint": 0
}
},
{
"xpub": "xpub6GiRC55CRvMEnS2CtwqrMNKDnpsogbX1tukjM2xWyW1PttVLSEVgDiJq7bWh6esAQWeQ9oGNR56RHqwzKLCzzneM6DGq91v8sA9DAJbUbtm",
"path": "/0/0",
"params": {
"pubKey": "027f30812a8f33ffeb44515d0fe9cc99041c2369f407ecc537d492d34da48c29d2",
"chainCode": "4f493067187019f78a773e3e559c699b98c0e82a53cbf76cf9ba5db8103062a0",
"depth": 5,
"index": 58402,
"parentFingerprint": 2966462100
}
},
{
"xpub": "xpub661MyMwAqRbcF6cBQfmTER34dwShTVu6x2h24nxhHxMX3jAHCP9DJYuLcHABvaMeaBcSMdcte8mhAMnCcBCypK5iGe6H33aUH8JWbstSKP9",
"path": "/0/0",
"params": {
"pubKey": "02ec33597217f00f1ad5689b0abbfd01d850c921d4560d1333f52f9f70eea2aafd",
"chainCode": "37b746ccdf38587d6a943f8007ef9e3012f52c73079f53c094f446cd43f9bb4f",
"depth": 0,
"index": 0,
"parentFingerprint": 0
}
}
]
},
"canSendInstant": true,
"permissions": "admin,spend,view",
"admin": {
"users": [
{
"user": "56f9e3b2cd8f2e5906530948fe1af2d2",
"permissions": "admin,spend,view"
}
]
},
"tags": [],
"approvalsRequired": 1,
"spendingAccount": true,
"pendingApprovals": [],
"balance": 30000000,
"instantBalance": 0,
"spendableConfirmedBalance": 0,
"confirmedBalance": 0,
"spendableBalance": 0,
"sent": 0,
"received": 30000000,
"unconfirmedSends": 0,
"unconfirmedReceives": 30000000
},
{
"_id": "5726855c0cb29c5b060918484524d6d9",
"id": "2N3qPHp7bNaL4hiztrzZCzCywryKUzb5aLE",
"label": "123labeling",
"isActive": true,
"type": "safehd",
"freeze": {},
"adminCount": 1,
"disableTransactionNotifications": false,
"private": {
"keychains": [
{
"xpub": "xpub661MyMwAqRbcFcyTCTTNVmYcAmPJ2yRJanFPv9To7n1wk5cZmgUpzY16pAz9m6XriziHnk6c4Y2Hov9HJSmWPSHdmSLn9KNBLMr5Qi29HGN",
"path": "/0/0",
"params": {
"pubKey": "032536e93aa4cd5feb0706d118b6ecf695d26544c00f92a2fb36ef9208ee216821",
"chainCode": "6c4dbaed05b8a09d2d64c3688e3fb53f12e62ef64b70ad808a700830e2063bb2",
"depth": 0,
"index": 0,
"parentFingerprint": 0
}
},
{
"xpub": "xpub6GiRC55CRvMEhQVtxhHwwpmG7NVyjT1SUuyYXfafsRDW4XoYRwzPp6Af5vY83hLN8vaFCzk9FdtUqdeXoQbS7fXNJU3eFYPnU1bfkjimsT4",
"path": "/0/0",
"params": {
"pubKey": "035d12105eab700c637ca9fbbea066beca88c6603f90f98c07a9e5b84713d6ff20",
"chainCode": "5670e6ede3379f33cc635981c7fbe9255c3f69a5e4868e5491e42bf3d5fb380a",
"depth": 5,
"index": 58400,
"parentFingerprint": 2966462100
}
},
{
"xpub": "xpub661MyMwAqRbcEZBgr8PUbKfGBaQ98GFp2wGdR6vDwTAzruGenMnn3PqDo9MMmzSsF8dFWgUfUUV1Yor2ErVrohBNHj9Ug81ih7VAohfnEQu",
"path": "/0/0",
"params": {
"pubKey": "024f7b2f85a3e0b859c4bdb975f9953973de4806300b2148afec66fb610af380a7",
"chainCode": "014ce166076a6045fb5a88fa4a51052d13c5449a4367d030e0f6bc058a9d0191",
"depth": 0,
"index": 0,
"parentFingerprint": 0
}
}
]
},
"canSendInstant": true,
"permissions": "admin,spend,view",
"admin": {
"users": [
{
"user": "56f9e3b2cd8f2e5906530948fe1af2d2",
"permissions": "admin,spend,view"
}
]
},
"tags": [],
"approvalsRequired": 1,
"spendingAccount": true,
"pendingApprovals": [],
"balance": 330000000,
"instantBalance": 0,
"spendableConfirmedBalance": 0,
"confirmedBalance": 0,
"spendableBalance": 0,
"sent": 0,
"received": 330000000,
"unconfirmedSends": 0,
"unconfirmedReceives": 330000000
}
]
希望有人做过类似的事情并且可以轻松发现错误。
干杯!
最佳答案
嗯,在您的以下代码中
docs.forEach(function(address) {
console.log(address);
var allWallets = [];
allWallets.push(address.playerWallet);
您在循环中定义 allWallets
数组并分配当前元素,即 address
,然后在下一个循环中重新定义 allWallets
数组as [] 并将下一个地址
插入其中。我想这就是问题的根源之一。你可能会这样做
var allWallets = [];
docs.forEach(function(address) {
console.log(address);
allWallets.push(address.playerWallet);
关于javascript - 比特币 - BitGO - 将所有钱包对象保存到对象数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36984319/
我需要将文本放在 中在一个 Div 中,在另一个 Div 中,在另一个 Div 中。所以这是它的样子: #document Change PIN
奇怪的事情发生了。 我有一个基本的 html 代码。 html,头部, body 。(因为我收到了一些反对票,这里是完整的代码) 这是我的CSS: html { backgroun
我正在尝试将 Assets 中的一组图像加载到 UICollectionview 中存在的 ImageView 中,但每当我运行应用程序时它都会显示错误。而且也没有显示图像。 我在ViewDidLoa
我需要根据带参数的 perl 脚本的输出更改一些环境变量。在 tcsh 中,我可以使用别名命令来评估 perl 脚本的输出。 tcsh: alias setsdk 'eval `/localhome/
我使用 Windows 身份验证创建了一个新的 Blazor(服务器端)应用程序,并使用 IIS Express 运行它。它将显示一条消息“Hello Domain\User!”来自右上方的以下 Ra
这是我的方法 void login(Event event);我想知道 Kotlin 中应该如何 最佳答案 在 Kotlin 中通配符运算符是 * 。它指示编译器它是未知的,但一旦知道,就不会有其他类
看下面的代码 for story in book if story.title.length < 140 - var story
我正在尝试用 C 语言学习字符串处理。我写了一个程序,它存储了一些音乐轨道,并帮助用户检查他/她想到的歌曲是否存在于存储的轨道中。这是通过要求用户输入一串字符来完成的。然后程序使用 strstr()
我正在学习 sscanf 并遇到如下格式字符串: sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c); 我理解 %[^:] 部分意味着扫描直到遇到 ':' 并将其分配给 a。:
def char_check(x,y): if (str(x) in y or x.find(y) > -1) or (str(y) in x or y.find(x) > -1):
我有一种情况,我想将文本文件中的现有行包含到一个新 block 中。 line 1 line 2 line in block line 3 line 4 应该变成 line 1 line 2 line
我有一个新项目,我正在尝试设置 Django 调试工具栏。首先,我尝试了快速设置,它只涉及将 'debug_toolbar' 添加到我的已安装应用程序列表中。有了这个,当我转到我的根 URL 时,调试
在 Matlab 中,如果我有一个函数 f,例如签名是 f(a,b,c),我可以创建一个只有一个变量 b 的函数,它将使用固定的 a=a1 和 c=c1 调用 f: g = @(b) f(a1, b,
我不明白为什么 ForEach 中的元素之间有多余的垂直间距在 VStack 里面在 ScrollView 里面使用 GeometryReader 时渲染自定义水平分隔线。 Scrol
我想知道,是否有关于何时使用 session 和 cookie 的指南或最佳实践? 什么应该和什么不应该存储在其中?谢谢! 最佳答案 这些文档很好地了解了 session cookie 的安全问题以及
我在 scipy/numpy 中有一个 Nx3 矩阵,我想用它制作一个 3 维条形图,其中 X 轴和 Y 轴由矩阵的第一列和第二列的值、高度确定每个条形的 是矩阵中的第三列,条形的数量由 N 确定。
假设我用两种不同的方式初始化信号量 sem_init(&randomsem,0,1) sem_init(&randomsem,0,0) 现在, sem_wait(&randomsem) 在这两种情况下
我怀疑该值如何存储在“WORD”中,因为 PStr 包含实际输出。? 既然Pstr中存储的是小写到大写的字母,那么在printf中如何将其给出为“WORD”。有人可以吗?解释一下? #include
我有一个 3x3 数组: var my_array = [[0,1,2], [3,4,5], [6,7,8]]; 并想获得它的第一个 2
我意识到您可以使用如下方式轻松检查焦点: var hasFocus = true; $(window).blur(function(){ hasFocus = false; }); $(win
我是一名优秀的程序员,十分优秀!